ci(release): automate GitHub Releases on tags and add Makefile release target

swadhin biswas committed 1 years ago
49d4252
1 parent 703e841
commit 49d4252
2 files changed
+77 -0
Showing 2 changed files+77-0
▼.github/workflows/release.yml
+60-0
1
+name: Release
2
+
3
+on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+jobs:
9
+ build-and-release:
10
+ name: Build and upload release artifacts
11
+ runs-on: ubuntu-latest
12
+
13
+ permissions:
14
+ contents: write # needed to upload assets and create releases
15
+
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Set up bash
21
+ run: echo "Using bash $BASH_VERSION"
22
+
23
+ - name: Extract version from tag
24
+ id: version
25
+ run: |
26
+ ref="${GITHUB_REF##*/}"
27
+ # ref is like v4.5.0
28
+ echo "tag=$ref" >> "$GITHUB_OUTPUT"
29
+ echo "version=${ref#v}" >> "$GITHUB_OUTPUT"
30
+
31
+ - name: Make release script executable
32
+ run: chmod +x tools/release.sh
33
+
34
+ - name: Build artifacts
35
+ run: |
36
+ ./tools/release.sh "${{ steps.version.outputs.version }}"
37
+
38
+ - name: Generate release notes
39
+ id: notes
40
+ run: |
41
+ if [[ -f RELEASE_NOTES.md ]]; then
42
+ echo 'notes<<EOF' >> $GITHUB_OUTPUT
43
+ cat RELEASE_NOTES.md >> $GITHUB_OUTPUT
44
+ echo 'EOF' >> $GITHUB_OUTPUT
45
+ else
46
+ echo 'notes=Release' >> $GITHUB_OUTPUT
47
+ fi
48
+
49
+ - name: Create GitHub Release
50
+ uses: softprops/action-gh-release@v2
51
+ with:
52
+ tag_name: ${{ steps.version.outputs.tag }}
53
+ name: ${{ steps.version.outputs.tag }}
54
+ body: ${{ steps.notes.outputs.notes }}
55
+ draft: false
56
+ prerelease: false
57
+ files: |
58
+ dist/ls-f-${{ steps.version.outputs.version }}.tar.gz
59
+ dist/ls-f-${{ steps.version.outputs.version }}.zip
60
+ dist/ls-f-${{ steps.version.outputs.version }}.SHA256SUMS
0
61
▼Makefile
+17-0
1
+SHELL := /usr/bin/env bash
2
+
3
+.PHONY: help release clean
4
+
5
+help:
6
+ @echo "Available targets:\n release VERSION=x.y.z Build release artifacts into dist/\n clean Remove dist/"
7
+
8
+release:
9
+ @if [[ -z "$$VERSION" ]]; then \
10
+ echo "ERROR: VERSION is required. Usage: make release VERSION=x.y.z"; \
11
+ exit 1; \
12
+ fi
13
+ @chmod +x tools/release.sh
14
+ @./tools/release.sh "$$VERSION"
15
+
16
+clean:
17
+ rm -rf dist
0
18