-
Notifications
You must be signed in to change notification settings - Fork 43
76 lines (67 loc) · 2.54 KB
/
release_canary.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Release Canary
on:
push:
branches-ignore:
- 'main'
- 'changeset-release/**'
- 'dependabot/**'
jobs:
release-canary:
name: Canary
if: ${{ github.repository == 'primer/primitives' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci --no-audit --no-fund --include=dev
- name: Build tokens
run: npm run build:tokens
- name: Create .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
- name: Publish canary version
run: |
echo "$( jq '.version = "0.0.0"' package.json )" > package.json
echo -e "---\n'@primer/primitives': patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md
npx changeset version --snapshot
npx changeset publish --tag canary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Output canary version number
id: commitStatus
uses: actions/github-script@v7
with:
script: |
const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`)
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: 'success',
context: `Published ${package.name}`,
description: package.version,
target_url: `https://unpkg.com/${package.name}@${package.version}/`
})
// Output the release version for next step
core.setOutput('packageVersion', package.version);
// Output the package name for next step
core.setOutput('packageName', package.name);
- name: Output canary version to summary
env:
VERSION: ${{ steps.commitStatus.outputs.packageVersion }}
PACKAGE_NAME: ${{ steps.commitStatus.outputs.packageName }}
run: |
echo "### Latest canary release" >> $GITHUB_STEP_SUMMARY
echo "[v$VERSION](https://unpkg.com/$PACKAGE_NAME@$VERSION/)" >> $GITHUB_STEP_SUMMARY