release.yml RawHistoryFolder
1name: release
2
3# Once each morning, create at most one tag for the unreleased conventional
4# commits on main. GitHub schedules in UTC, so both possible UTC offsets are
5# triggered and the first step keeps only the 07:00 Europe/Paris run.
6on:
7 schedule:
8 - cron: "0 5,6 * * *"
9 workflow_dispatch:
10
11permissions:
12 contents: write
13
14concurrency:
15 group: release
16 cancel-in-progress: false
17
18jobs:
19 tag:
20 runs-on: ubuntu-latest
21 outputs:
22 tag: ${{ steps.version.outputs.tag }}
23 steps:
24 - name: Check the Paris release time
25 id: release-time
26 shell: bash
27 env:
28 EVENT_NAME: ${{ github.event_name }}
29 TZ: Europe/Paris
30 run: |
31 if [ "$EVENT_NAME" = workflow_dispatch ] || [ "$(date +%H)" = 07 ]; then
32 echo "run=true" >> "$GITHUB_OUTPUT"
33 fi
34
35 - name: Check out main
36 if: steps.release-time.outputs.run == 'true'
37 uses: actions/checkout@v4
38 with:
39 fetch-depth: 0
40 fetch-tags: true
41 ref: main
42
43 - name: Compute the next release tag
44 if: steps.release-time.outputs.run == 'true'
45 id: version
46 shell: bash
47 run: |
48 set -euo pipefail
49 if git log -1 --format=%B | grep -Fq '[release=skip]'; then
50 echo "The latest commit requested that the release be skipped."
51 exit 0
52 fi
53 tag=$(bash .github/scripts/next-release-tag.sh)
54 if [ -z "$tag" ]; then
55 echo "No releasable conventional commits for this run."
56 exit 0
57 fi
58 echo "Releasing $tag from $(git rev-parse --short HEAD)"
59 echo "tag=$tag" >> "$GITHUB_OUTPUT"
60
61 - name: Create and push the tag
62 if: steps.version.outputs.tag != ''
63 env:
64 TAG: ${{ steps.version.outputs.tag }}
65 run: |
66 git config user.name "github-actions[bot]"
67 git config user.email "github-actions[bot]@users.noreply.github.com"
68 git tag -a "$TAG" -m "release $TAG"
69 git push origin "$TAG"
70
71 release:
72 needs: tag
73 if: needs.tag.outputs.tag != ''
74 permissions:
75 contents: write
76 uses: bnema/gh-actions/.github/workflows/go-release.yml@main
77 with:
78 go-version: "1.26"
79 # The reusable workflow fetches tags before this command, ensuring
80 # GoReleaser produces artifacts and notes for the newly created tag.
81 pre-command: git checkout --detach "${{ needs.tag.outputs.tag }}"