-
Notifications
You must be signed in to change notification settings - Fork 3
153 lines (134 loc) · 4.96 KB
/
Copy pathrelease.yml
File metadata and controls
153 lines (134 loc) · 4.96 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
name: Release
on:
push:
# Ignore merge queue branches
branches-ignore:
- 'gh-readonly-queue/**'
tags-ignore:
- '**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write # Required for OIDC
contents: write
pull-requests: write
checks: write
statuses: write
jobs:
release-main:
if: github.repository == 'primer/doctocat-nextjs' && github.ref_name == 'main'
name: Main
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
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@v6
with:
node-version: 24
- name: Install dependencies
run: npm ci
- uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42
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
# Please keep this up-to-date if you're changing the SHA below
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba
with:
title: Release tracking
publish: npm run release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
release-candidate:
if: github.repository == 'primer/doctocat-nextjs' && github.ref_name == 'changeset-release/main'
name: Candidate
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
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@v6
with:
node-version: 24
- name: Install dependencies
run: npm ci
- name: Publish release candidate
run: |
npm exec --workspaces -- ../../packages/repo-configs/scripts/prepare-release-candidate
# We use OIDC token here because we don't need Bot to trigger additional workflows
npx changeset publish --tag next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Output release candidate version
uses: actions/github-script@v4.0.2
with:
script: |
const paths = ['theme'].forEach((path) => {
const package = require(`${process.env.GITHUB_WORKSPACE}/packages/${path}/package.json`)
github.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}/`
})
})
release-canary:
if: github.repository == 'primer/doctocat-nextjs' && github.ref_name != 'main' && github.ref_name != 'changeset-release/main'
name: Canary
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
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@v6
with:
node-version: 24
- name: Install dependencies
run: npm ci
- uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42
id: app-token
with:
app-id: ${{ vars.PRIMER_APP_ID_SHARED }}
private-key: ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }}
- name: Publish canary release
run: |
npm exec --workspaces -- ../../packages/repo-configs/scripts/prepare-canary
npx changeset publish --tag canary
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Output canary version
uses: actions/github-script@v4.0.2
with:
script: |
const paths = ['theme'].forEach((path) => {
const package = require(`${process.env.GITHUB_WORKSPACE}/packages/${path}/package.json`)
github.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}/`
})
})