From 034de92456a84d8823fb847d13f7e3899a0d016e Mon Sep 17 00:00:00 2001 From: omicron Date: Sat, 20 May 2023 01:09:36 +0200 Subject: [PATCH] Add gitlab/github CI for testing and releases --- .github/workflows/create-release.yml | 84 ++++++++++++++++++++++++++++ .github/workflows/test-commits.yml | 13 +++++ .gitlab-ci.yml | 84 ++++++++++++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 .github/workflows/create-release.yml create mode 100644 .github/workflows/test-commits.yml create mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..772ced6 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,84 @@ +name: Create Release +on: + push: + tags: + - 'v*' +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v3 + - name: build release archives + run: make + - name: create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: LibFreeMedia ${{ github.ref_name }} + body: LibFreeMedia ${{ github.ref_name }} + draft: false + prerelease: false + - name: upload embed zip archive + id: upload-embed-zip-archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./release/LibFreeMedia-embed.zip + asset_name: LibFreeMedia-embed-${{ github.ref_name }}.zip + asset_content_type: application/zip + - name: upload embed tar.gz archive + id: upload-embed-targz-archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./release/LibFreeMedia-embed.tar.gz + asset_name: LibFreeMedia-embed${{ github.ref_name }}.tar.gz + asset_content_type: application/x-gtar + - name: upload embed tar.xz archive + id: upload-embed-tarxz-archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./release/LibFreeMedia-embed.tar.xz + asset_name: LibFreeMedia-embed-${{ github.ref_name}}.tar.xz + asset_content_type: application/x-gtar + - name: upload standalone zip archive + id: upload-standalone-zip-archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./release/LibFreeMedia-standalone.zip + asset_name: LibFreeMedia-standalone-${{ github.ref_name }}.zip + asset_content_type: application/zip + - name: upload standalone tar.gz archive + id: upload-standalone-targz-archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./release/LibFreeMedia-standalone.tar.gz + asset_name: LibFreeMedia-standalone-${{ github.ref_name }}.tar.gz + asset_content_type: application/x-gtar + - name: upload standalone tar.xz archive + id: upload-standalone-tarxz-archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./release/LibFreeMedia-standalone.tar.xz + asset_name: LibFreeMedia-standalone-${{ github.ref_name }}.tar.xz + asset_content_type: application/x-gtar diff --git a/.github/workflows/test-commits.yml b/.github/workflows/test-commits.yml new file mode 100644 index 0000000..9030822 --- /dev/null +++ b/.github/workflows/test-commits.yml @@ -0,0 +1,13 @@ +name: Test Commit +on: + push: + branches: + - '*' +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v3 + - name: build release archives + run: make diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..2150c77 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,84 @@ +stages: + - test + - package + - release + +# Run the tests only on commits, never on tags for now this just builds the +# release archives to make sure that works +test: + stage: test + rules: + - if: $CI_COMMIT_BRANCH + image: alpine:3 + before_script: + - echo PACKAGE_JOB_ID=$CI_JOB_ID >> package.env + - apk add xz 7zip make + script: + - make + +# Build the release archives and keep them forever as an artifact. Only runs on +# tag pushes +package: + stage: package + rules: + - if: $CI_COMMIT_TAG + image: alpine:3 + before_script: + - echo PACKAGE_JOB_ID=$CI_JOB_ID >> package.env + - apk add xz 7zip make + script: + - make + image: alpine:3 + before_script: + - echo PACKAGE_JOB_ID=$CI_JOB_ID >> package.env + - apk add xz 7zip make + script: + - make + artifacts: + expire_in: never + paths: + - release/LibFreeMedia-embed.tar.gz + - release/LibFreeMedia-embed.tar.xz + - release/LibFreeMedia-embed.zip + - release/LibFreeMedia-standalone.tar.gz + - release/LibFreeMedia-standalone.tar.xz + - release/LibFreeMedia-standalone.zip + reports: + dotenv: package.env + +# Create a release with the previously generated artifacts. Only runs on tag +# pushes +release: + stage: release + rules: + - if: $CI_COMMIT_TAG + image: registry.gitlab.com/gitlab-org/release-cli:latest + script: + - echo 'Creating release' + needs: + - job: package + artifacts: true + release: + tag_name: $CI_COMMIT_TAG + name: 'LibFreeMedia $CI_COMMIT_TAG' + description: 'LibFreeMedia $CI_COMMIT_TAG' + assets: + links: + - name: 'LibFreeMedia embedable release' + url: 'https://gitlab.com/omicron-oss/wow/libfreemedia/-/jobs/${PACKAGE_JOB_ID}/artifacts/raw/release/LibFreeMedia-embed.zip' + filepath: '/archive/freemedia-embed-zip' + - name: 'LibFreeMedia embedable release (tar.xz archive)' + url: 'https://gitlab.com/omicron-oss/wow/libfreemedia/-/jobs/${PACKAGE_JOB_ID}/artifacts/raw/release/LibFreeMedia-embed.tar.xz' + filepath: '/archive/freemedia-embed-tarxz' + - name: 'LibFreeMedia embedable release (tar.gz archive)' + url: 'https://gitlab.com/omicron-oss/wow/libfreemedia/-/jobs/${PACKAGE_JOB_ID}/artifacts/raw/release/LibFreeMedia-embed.tar.gz' + filepath: '/archive/freemedia-embed-targz' + - name: 'LibFreeMedia standalone addon' + url: 'https://gitlab.com/omicron-oss/wow/libfreemedia/-/jobs/${PACKAGE_JOB_ID}/artifacts/raw/release/LibFreeMedia-standalone.zip' + filepath: '/archive/freemedia-standalone-zip' + - name: 'LibFreeMedia standalone addon (tar.xz archive)' + url: 'https://gitlab.com/omicron-oss/wow/libfreemedia/-/jobs/${PACKAGE_JOB_ID}/artifacts/raw/release/LibFreeMedia-standalone.tar.xz' + filepath: '/archive/freemedia-standalone-tarxz' + - name: 'LibFreeMedia standalone addon (tar.gz archive)' + url: 'https://gitlab.com/omicron-oss/wow/libfreemedia/-/jobs/${PACKAGE_JOB_ID}/artifacts/raw/release/LibFreeMedia-standalone.tar.gz' + filepath: '/archive/freemedia-standalone-targz'