title |
---|
GitHub Actions |
The following config declares the release
action that run on all branches. The job will either release:
- a new
latest
version frombaseBranch
- a
canary
build from a pull request (only on the main fork and if your package manager plugin implements them)
.github/workflows/release.yml
⚠️ You must use some sort of action that implementsskip ci
functionality (as seen below). Otherwise you will get stuck in a release loop!
name: Release
on: [push]
jobs:
release:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- uses: actions/checkout@v2
- name: Prepare repository
run: git fetch --unshallow --tags
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: yarn-deps-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-deps-${{ hashFiles('yarn.lock') }}
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn install --frozen-lockfile
yarn build
npx auto shipit
If you are publishing to the Github Package Registry you will need to change the NPM_TOKEN
token secret to match the following:
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn install --frozen-lockfile
yarn build
npx auto shipit
This will use your GITHUB_TOKEN
to publish to the Github Package Registry.
The NODE_AUTH_TOKEN
variable is required the .npmrc
that actions/setup-node@v1
sets up.
If you aren't using actions/setup-node@v1
replace the variable name NODE_AUTH_TOKEN
with NPM_TOKEN
and the .npmrc
auto
will handle authentication instead.
If you are having problems make sure you have done the following:
- Any required secrets for plugins are set (e.g.
NPM_TOKEN
with the NPM plugin) - Update references of
<your-github-user>
,<project-owner>
, and<project-repo>
with the appropriate values
GitHub actions require a little more setup to use auto
with branch protection.
steps:
- uses: actions/checkout@v2
with:
# Ensure that git uses your token with write access to the repo
token: ${{ secrets.GH_TOKEN }}
- name: Prepare repository
# Fetch full git history and tags
run: git fetch --unshallow --tags