because I got bored of customising my CV for every job
1name: Create release
2
3on:
4 workflow_dispatch:
5 inputs:
6 bump:
7 description: "Version bump type"
8 required: true
9 type: choice
10 options:
11 - patch
12 - minor
13 - major
14
15permissions:
16 contents: write
17
18jobs:
19 release:
20 name: Create tag and release
21 runs-on: ubuntu-latest
22 steps:
23 - uses: actions/create-github-app-token@v1
24 id: app-token
25 with:
26 app-id: ${{ vars.RIOTBYTE_BOT_APP_ID }}
27 private-key: ${{ secrets.RIOTBYTE_BOT_PRIVATE_KEY }}
28
29 - uses: actions/checkout@v4
30 with:
31 fetch-depth: 0
32
33 - name: Determine next version
34 id: version
35 run: |
36 LATEST=$(git tag --list --sort=-v:refname '[0-9]*.[0-9]*.[0-9]*' --merged HEAD | head -n1)
37
38 if [ -z "$LATEST" ]; then
39 LATEST="0.0.0"
40 fi
41
42 IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST"
43
44 case "${{ inputs.bump }}" in
45 major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
46 minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
47 patch) PATCH=$((PATCH + 1)) ;;
48 esac
49
50 NEXT="${MAJOR}.${MINOR}.${PATCH}"
51 echo "previous=${LATEST}" >> "$GITHUB_OUTPUT"
52 echo "next=${NEXT}" >> "$GITHUB_OUTPUT"
53 echo "Bumping ${LATEST} → ${NEXT} (${{ inputs.bump }})"
54
55 - name: Create tag and GitHub release
56 env:
57 GH_TOKEN: ${{ steps.app-token.outputs.token }}
58 run: |
59 gh release create "${{ steps.version.outputs.next }}" \
60 --target "${{ github.sha }}" \
61 --title "${{ steps.version.outputs.next }}" \
62 --generate-notes \
63 --notes-start-tag "${{ steps.version.outputs.previous }}"