Skip to content

Commit 604f644

Browse files
committed
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.
1 parent 75e3687 commit 604f644

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: On-Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+'
7+
- 'v[0-9]+.[0-9]+-[0-9a-zA-Z]+'
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
create-release:
14+
name: create-release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Get release version from tag
19+
if: env.VERSION == ''
20+
run: |
21+
# Get the version without the `v` prefix
22+
tag=${{ github.ref_name }}
23+
echo "VERSION=${tag:1}" >> $GITHUB_ENV
24+
- name: Show the version
25+
run: |
26+
echo "Version is: $VERSION"
27+
- name: Create Github release
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
gh release create v$VERSION --draft --verify-tag --title v$VERSION
32+
outputs:
33+
version: ${{ env.VERSION }}
34+
35+
create-archive:
36+
name: create-archive
37+
needs: ['create-release']
38+
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
format: [zip, tar.gz]
42+
steps:
43+
- uses: actions/checkout@v4
44+
- name: Create archive
45+
shell: bash
46+
env:
47+
format: ${{ matrix.format }}
48+
run: |
49+
version="${{ needs.create-release.outputs.version }}"
50+
archive_name="zim-testing-suite-${version}"
51+
git archive --prefix="${archive_name}/" --output ${archive_name}.${{ env.format }} ${version}:data/
52+
53+
- name: Upload archive
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
format: ${{ matrix.format }}
57+
run: |
58+
version="${{ needs.create-release.outputs.version }}"
59+
archive="zim-testing-suite-${version}.${{ env.format }}"
60+
gh release upload "v$version" $archive

0 commit comments

Comments
 (0)