-
Notifications
You must be signed in to change notification settings - Fork 668
156 lines (135 loc) · 5.27 KB
/
Copy pathrelease.yml
File metadata and controls
156 lines (135 loc) · 5.27 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Release
on:
push:
# Ignore merge queue branches and all tags
branches-ignore:
- 'gh-readonly-queue/**'
tags-ignore:
- '**'
pull_request:
types: [labeled, synchronize]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write # Required for OIDC
contents: read
checks: write
statuses: write
jobs:
release-main:
if: github.event_name != 'pull_request' && github.ref_name == 'main'
name: Main
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
persist-credentials: false
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1
id: app-token
with:
app-id: ${{ vars.PRIMER_APP_ID_SHARED }}
private-key: ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }}
- name: Create release pull request or publish to npm
id: changesets
# Uses SHA for security hardening
# Currently pointing at a commit for the v1.4.1 tag
# Please keep this up-to-date if you're changing the SHA below
uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d
with:
title: Release tracking
commitMode: github-api
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: npm run release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Upload versions json file
uses: primer/.github/.github/actions/upload-versions@v2.4.0
release-candidate:
if: github.event_name != 'pull_request' && github.ref_name == 'changeset-release/main'
name: Candidate (@next)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
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@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Publish release candidate
run: |
if [[ -f '.changeset/pre.json' ]]; then
npx changeset pre exit
npx changeset version --snapshot
else
for pkg_json_path in packages/react/package.json packages/styled-react/package.json packages/mcp/package.json; do
version=$(jq -r .version $pkg_json_path)
echo "$( jq ".version = \"$(echo $version)-rc.$(git rev-parse --short HEAD)\"" $pkg_json_path )" > $pkg_json_path
done
fi
npx changeset publish --tag next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Report versions
uses: primer/.github/.github/actions/report-versions@v2.4.0
- name: Upload versions json file
uses: primer/.github/.github/actions/upload-versions@v2.4.0
release-canary:
name: Canary
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
(
(github.event.action == 'labeled' && github.event.label.name == 'Canary Release') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'Canary Release'))
)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
ref: ${{ github.event.pull_request.head.sha }}
# 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@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build --if-present
- name: Publish canary release
run: |
if [[ -f '.changeset/pre.json' ]]; then
npx changeset pre exit
fi
echo -e "---\n$( jq .name packages/react/package.json ): 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: Report versions
uses: primer/.github/.github/actions/report-versions@v2.4.0
- name: Upload versions json file
uses: primer/.github/.github/actions/upload-versions@v2.4.0