Repository navigation
feat: use gh api to push tags - #37
Merged
Merged
Conversation
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Release tags are now created through the GitHub API instead of
git tag+git push.A
git pushof a tag whose commit touches.github/workflows/is rejected for thedefault
GITHUB_TOKEN:! [remote rejected] v0.1.0 -> v0.1.0 (refusing to allow a GitHub App to create or
update workflow .github/workflows/release.yml without workflows permission)
GITHUB_TOKENauthenticates as a GitHub App and cannot be granted theworkflowspermission, so consumers were forced to supply a PAT with the
workflowscope (andwire it into
actions/checkout'stoken:). Worse, the protection is inconsistent fortag pushes — it can pass on one release and reject the next depending on whether the
tagged commit is seen as modifying a workflow file — which made it hard to diagnose.
Creating the tag via the API (
gh api .../git/tagsthen.../git/refs) points a refat a commit that already exists on the server. There's no push and no workflow-file
push protection, so a plain
GITHUB_TOKENwithcontents: writeis sufficient — noPAT, no
workflowscope — even in repos that contain.github/workflows/files.Type of change
How Has This Been Tested?
Extracted the logic into a
create_taghelper (scripts/tag.sh) and addedtests/tag.bats, which stubsgh(andgit) onPATHto verify: both APIendpoints are hit; the tag object is built from the commit SHA/message/type; the ref
is pointed at the returned tag-object SHA (not the commit SHA); and
git pushisnever invoked. Ran the full suite and bash syntax checks locally.
bats tests/passes (81 tests: 4 new + 77 existing)Test Configuration:
create-tag: truewith the defaultGITHUB_TOKEN(no PAT), in a repo containing.github/workflows/Checklist
set -euo pipefail, quoted expansions)action.ymldescriptions where relevant