Tag a Release #183
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Tag a new release using https://github.com/marketplace/actions/conventional-commits-versioner-action | |
| # | |
| # This is easier than having to run manual `git` operations on a local clone. | |
| # It also runs on a schedule so we don't leave commits unreleased indefinitely | |
| # (avoiding users having to ping "hey could someone cut a release"). | |
| name: Tag a Release | |
| on: | |
| # Allow devs to tag manually through the GitHub UI. | |
| # For example after landing a fix that customers are waiting for. | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 15 * * *" # Daily at 3PM UTC | |
| jobs: | |
| tag: | |
| permissions: | |
| contents: write # allow create tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new-tag: ${{ steps.ccv.outputs.new-tag }} | |
| new-tag-version: ${{ steps.ccv.outputs.new-tag-version }} | |
| new-tag-version-type: ${{ steps.ccv.outputs.new-tag-version-type }} | |
| recently-tagged: ${{ steps.recent-tag.outputs.recently-tagged }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| # Need enough history to find the prior release tag | |
| fetch-depth: 0 | |
| - name: Check if there is a recent tag | |
| id: recent-tag | |
| # Only skip on cron trigger, not manual trigger | |
| if: github.event_name == 'schedule' | |
| run: | | |
| # This is a trade-off between making too many releases, | |
| # which overwhelms BCR maintainers and over-notifies users, | |
| # and releasing too infrequently which delays delivery of bugfixes and features. | |
| MAX_AGE=1209600 # 2 weeks | |
| TAG=$(git describe --tags --match 'v[0-9]*.[0-9]*.[0-9]*' --abbrev=0 2>/dev/null) || { | |
| echo "No matching tag — continue workflow." | |
| exit 0 | |
| } | |
| TAG_TIME=$(git log -1 --format=%ct "$TAG") | |
| NOW=$(date +%s) | |
| AGE=$((NOW - TAG_TIME)) | |
| echo "Latest tag: $TAG ($AGE seconds ago)" | |
| if [ "$AGE" -lt "$MAX_AGE" ]; then | |
| echo "recently-tagged=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Bump tag if necessary | |
| id: ccv | |
| if: github.event_name != 'schedule' || steps.recent-tag.outputs.recently-tagged != 'true' | |
| uses: smlx/[email protected] | |
| release: | |
| needs: tag | |
| uses: ./.github/workflows/release.yaml | |
| with: | |
| tag_name: ${{ needs.tag.outputs.new-tag-version }} | |
| secrets: | |
| publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }} | |
| if: needs.tag.outputs.new-tag == 'true' && needs.tag.outputs.new-tag-version-type != 'major' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| attestations: write |