Repository navigation
Publish to pub.dev from a tag via trusted publishing - #16
Merged
Merged
Conversation
Publishing from CI means no long-lived pub.dev token on a developer machine. pub.dev's trusted publishing exchanges a GitHub OIDC token for upload authorization, so there is no secret to store or rotate. The publish job reuses the Dart team's publish workflow and runs only after the test workflow passes, so a tagged commit cannot ship untested.
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.
Publishes on a version tag using pub.dev's trusted publishing, so there is no pub.dev token stored on a developer machine. pub.dev exchanges a GitHub OIDC token for upload authorization instead.
publish.ymlruns on tags matchingv[0-9]+.[0-9]+.[0-9]+, waits for the test workflow, then calls the Dart team's reusable publish workflow.test.ymlgainsworkflow_callso the publish job can depend on it. A tagged commit cannot ship untested as a result.Setup required before the first tag
The workflow alone is not enough. pub.dev has to know it should trust this repository. That is a web UI setting I cannot make:
justintout/cronparsev{{version}}The package already exists on pub.dev (0.1.1), which is the prerequisite. pub.dev only allows automating publishing for existing packages.
Optionally, tick Require GitHub Actions environment and name it
pub.dev, then create a matching environment in the repository settings and addenvironment: pub.devto the publish job. That prevents anyone with tag-push access from publishing without the environment's protection rules. Not enabled here, since the repository has a single maintainer.Publishing 0.2.0
Once the pub.dev setting is in place:
pubspec.yamlis already at 0.2.0, which must match the tag. Progress appears under the repository's Actions tab, and the publish is recorded in pub.dev's audit log.