Sub topic 15
Versioning and releasing for other repositories
This chapter assumes you can write an action.yml with inputs and outputs, and that you know Git tags and branches. It covers how other repositories refer to your action, and how to release changes without breaking them.
How callers refer to a version
A workflow in another repository names your action with a Git ref after the @:
steps:
- uses: my-org/greet-action@v1
- uses: my-org/[email protected]
- uses: my-org/greet-action@3f5a1c9d7e2b4a6c8d0e1f2a3b4c5d6e7f8a9b0c
- uses: my-org/tools/.github/actions/greet@v1The ref can be a major tag, an exact tag, a branch or a full commit SHA. The last line shows an action in a subdirectory, where the path goes between the repository name and the ref. GitHub resolves the ref when the job starts and runs the action.yml found at that commit.
Release with semantic versions and a moving major tag
Use semantic versioning for exact releases. A caller who wants fixes without editing their workflow needs a major tag such as v1. You move that tag forward each time you release a compatible change.
git tag -a v1.2.0 -m "Release v1.2.0"
git push origin v1.2.0
# Point v1 at the same commit
git tag -fa v1 -m "Update v1 to v1.2.0" "v1.2.0^{commit}"
git push origin v1 --forceThen publish a GitHub release for v1.2.0 and write release notes. Callers who track v1 get the new code on their next run.
flowchart LRWhat counts as a breaking change
Callers depend on your public interface, so treat these changes as major version bumps:
- Renaming or removing an input or output.
- Making an optional input required.
- Changing a default in a way that changes behavior.
- Changing the format of an output value.
Adding an optional input with a default, or a new output, is a minor release. Bug fixes are patch releases.
Choosing a pin
| Reference | Updates automatically | Trade-off |
|---|---|---|
| `@main` | Every push | Unreviewed changes can break callers |
| `@v1` | On each compatible release | Convenient, but the tag can be moved |
| `@v1.2.0` | Never | Stable, but usually stays unmoved by convention only |
| `@<full SHA>` | Never | Immutable, so it is the safest choice |
Tags can be force-pushed, so a SHA is the only reference that cannot change underneath a caller. Security-sensitive callers should pin to a SHA and let a tool such as Dependabot propose updates.
Access across repositories
A public repository's action can be used by anyone. For a private repository, open its Settings, then Actions, then General, and set Access so other repositories in your organization or user account can use it. Without this setting, callers fail to resolve the action.
Exercise
Your action is at v1.4.0. You add an optional input with a default and fix a bug. Which tags do you create or move, and why?
Show answer
Create v1.5.0 because adding an optional input is a compatible feature, and move v1 to the same commit so callers tracking v1 receive it. A caller pinned to a SHA or to v1.4.0 is unaffected.