Skip to content

Commit 67a451e

Browse files
authored
Add more release workflows
1 parent bd6eb64 commit 67a451e

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v2
12+
with:
13+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
14+
fetch-depth: 0
15+
persist-credentials: false
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 14
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Create release pull request or publish to npm
26+
id: changesets
27+
uses: changesets/action@master
28+
with:
29+
title: Release Tracking
30+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
31+
publish: npm run release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
34+
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release (candidate)
2+
on:
3+
push:
4+
branches:
5+
- 'changeset-release/main'
6+
7+
jobs:
8+
release:
9+
if: ${{ github.repository == 'primer/eslint-plugin-primer-react' }}
10+
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
with:
16+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
17+
fetch-depth: 0
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: 14.x
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Build
28+
run: npm run build --if-present
29+
30+
- name: Create .npmrc
31+
run: |
32+
cat << EOF > "$HOME/.npmrc"
33+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
34+
EOF
35+
env:
36+
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
37+
38+
- name: Publish release candidate
39+
run: |
40+
version=$(jq -r .version package.json)
41+
echo "$( jq ".version = \"$(echo $version)-rc.$(git rev-parse --short HEAD)\"" package.json )" > package.json
42+
yarn publish --tag next
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Output release candidate version number
47+
uses: actions/[email protected]
48+
with:
49+
script: |
50+
const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`)
51+
github.repos.createCommitStatus({
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
sha: context.sha,
55+
state: 'success',
56+
context: `Published ${package.name}`,
57+
description: package.version,
58+
target_url: `https://unpkg.com/${package.name}@${package.version}/`
59+
})

0 commit comments

Comments
 (0)