From a82aab8e7941cbcab80db58027c9330185090786 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 14 Jun 2024 17:31:19 +0200 Subject: [PATCH] Add a workflow to automatically create a relase on tag. - Triggered on x.y (or x.y-foo) tags - Zip and Tar archive are build and automatically added to the release. - Release is created as draft. User still have manually to publish on Github UI. --- .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ab74313 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: On-Release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+-[0-9a-zA-Z]+' + +permissions: + contents: write + +jobs: + create-release: + name: create-release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Get release version from tag + if: env.VERSION == '' + run: | + # Get the version without the `v` prefix + tag=${{ github.ref_name }} + echo "VERSION=${tag:1}" >> $GITHUB_ENV + - name: Show the version + run: | + echo "Version is: $VERSION" + - name: Create Github release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v$VERSION --draft --verify-tag --title v$VERSION + outputs: + version: ${{ env.VERSION }} + + create-archive: + name: create-archive + needs: ['create-release'] + runs-on: ubuntu-latest + strategy: + matrix: + format: [zip, tar.gz] + steps: + - uses: actions/checkout@v4 + - name: Create archive + shell: bash + env: + format: ${{ matrix.format }} + run: | + version="${{ needs.create-release.outputs.version }}" + archive_name="zim-testing-suite-${version}" + git archive --prefix="${archive_name}/" --output ${archive_name}.${{ env.format }} v${version}:data/ + + - name: Upload archive + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + format: ${{ matrix.format }} + run: | + version="${{ needs.create-release.outputs.version }}" + archive="zim-testing-suite-${version}.${{ env.format }}" + gh release upload "v$version" $archive