Skip to content

ci: drop redundant main-push build; add concurrency cancel - #22

Merged
attson merged 1 commit into
mainfrom
ci/skip-redundant-main-build
May 16, 2026
Merged

ci: drop redundant main-push build; add concurrency cancel#22
attson merged 1 commit into
mainfrom
ci/skip-redundant-main-build

Conversation

@attson

@attson attson commented May 16, 2026

Copy link
Copy Markdown
Owner

Summary

build.yml was triggering on push: branches: [main], but every artifact upload and the release job are gated on if: startsWith(github.ref, 'refs/tags/v'). So each squash-merge into main kicked off a full matrix build (linux × 2 arch + darwin × 2 arch + windows) that ran vet/test/build and then skipped every output step — pure waste, typically 10+ minutes of CI per merge for an OSS project where every change lands via PR (which had already verified the same code).

Changes

on:
  push:
    tags: ['v*']            # was: branches: [main], tags: ['v*']
  pull_request:
    branches: [main]
  workflow_dispatch:

concurrency:
  group: build-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
  • Drop push: branches:[main] — PR already gates merges to main. Direct pushes to main are rare and (per project convention) avoided.
  • Keep push: tags:['v*'] — release flow is unchanged: git tag vX.Y.Z && git push --tags still triggers the full matrix build + artifact upload + GitHub Release.
  • Keep pull_request and workflow_dispatch — pre-merge gate and manual re-run.
  • Add concurrency keyed on github.ref. When a PR is updated multiple times in quick succession, the older run is cancelled. Tag pushes use a distinct ref (refs/tags/vX.Y.Z) so a release build is never aborted by an unrelated PR update.

What still works

  • Open a PR → CI runs (same as before, just without the duplicate on merge)
  • Merge → no CI run (PR already verified)
  • Push a release tag → full matrix build + artifacts + GitHub Release (unchanged)

What changes

  • Direct pushes to main (bypassing PR) will no longer run CI. We don't do this, so accepting the trade-off.

Test Plan

  • This PR's own CI run uses the new concurrency group (visible under "Actions" once the PR is open)
  • After merge, no follow-up build runs on the resulting main commit
  • Next time you git tag vX.Y.Z && git push --tags, the release flow still produces full artifacts

The build workflow used to run on push-to-main, but every artifact
upload and release step is gated on a tag ref. So the main-push build
just re-ran vet/build/test on the same code the PR had already
verified, producing nothing. For a single-developer project where
everything lands via PR, the second run is pure waste — usually 10+
minutes of CI per merge.

Triggers now:
  pull_request → branches: [main]   (pre-merge gate, same as before)
  push         → tags: ['v*']       (release build + artifact upload)
  workflow_dispatch                 (manual)

Also adds a concurrency group keyed on github.ref. When a PR is updated
multiple times in quick succession, in-flight runs for the older HEAD
are cancelled. Tag pushes get their own group key (refs/tags/vX.Y.Z),
so a release in flight is never aborted by a concurrent PR update.

No change to artifact behavior: releases still come from `git tag vX.Y`
+ `git push --tags`. Direct pushes to main (rare; we go via PR) will no
longer run CI — acceptable trade-off for the time saved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant