Skip to content

Commit 6874747

Browse files
authored
Combine release workflows (#67)
* Combine release workflows * Use npx * update nvmrc
1 parent 89d15e1 commit 6874747

7 files changed

Lines changed: 136 additions & 128 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "Doctocat Dev Container",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:24",
4+
5+
// Configure tool-specific properties.
6+
"customizations": {
7+
"vscode": {
8+
"extensions": [
9+
"dbaeumer.vscode-eslint",
10+
"esbenp.prettier-vscode",
11+
"GitHub.copilot",
12+
"GitHub.copilot-chat"
13+
]
14+
}
15+
},
16+
17+
// Features to add to the dev container. More info: https://containers.dev/features.
18+
"features": {
19+
"ghcr.io/devcontainers/features/git:1": {},
20+
"ghcr.io/devcontainers/features/github-cli:1": {}
21+
},
22+
23+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
24+
"forwardPorts": [8000, 9000],
25+
26+
// Use 'postCreateCommand' to run commands after the container is created.
27+
"postCreateCommand": "npm install",
28+
29+
// Configure the container to run as a non-root user with the same UID/GID as your local user.
30+
"remoteUser": "node"
31+
}

.github/workflows/release.yml

Lines changed: 99 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,107 @@ name: Release
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- next-minor
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
id-token: write # Required for OIDC
12+
contents: read
13+
checks: write
14+
statuses: write
815

916
jobs:
10-
release:
17+
release-main:
1118
if: github.ref_name == 'main'
12-
name: Release
13-
uses: primer/.github/.github/workflows/release.yml@v1.0.0
19+
name: Main
20+
uses: primer/.github/.github/workflows/release.yml@v2.3.1
1421
secrets:
1522
gh_token: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
16-
npm_token: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
23+
24+
release-candidate:
25+
if: ${{ github.repository == 'primer/doctocat-nextjs' && github.ref_name == 'changeset-release/main' }}
26+
name: Candidate
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v5
31+
with:
32+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
33+
fetch-depth: 0
34+
35+
- name: Set up Node
36+
uses: actions/setup-node@v6
37+
with:
38+
node-version: 24
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Publish release candidate
44+
run: |
45+
npm exec --workspaces -- ../../packages/repo-configs/scripts/prepare-release-candidate
46+
npx changeset publish --tag next
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Output canary version
51+
uses: actions/github-script@v4.0.2
52+
with:
53+
script: |
54+
const paths = ['theme'].forEach((path) => {
55+
const package = require(`${process.env.GITHUB_WORKSPACE}/packages/${path}/package.json`)
56+
github.repos.createCommitStatus({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
sha: context.sha,
60+
state: 'success',
61+
context: `Published ${package.name}`,
62+
description: package.version,
63+
target_url: `https://unpkg.com/${package.name}@${package.version}/`
64+
})
65+
})
66+
67+
release-canary:
68+
if: ${{ github.repository == 'primer/doctocat-nextjs' && github.ref_name != 'main' && github.ref_name != 'changeset-release/main' }}
69+
name: Canary
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Checkout repository
73+
uses: actions/checkout@v5
74+
with:
75+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
76+
fetch-depth: 0
77+
78+
- name: Set up Node
79+
uses: actions/setup-node@v6
80+
with:
81+
node-version: 24
82+
83+
- name: Install dependencies
84+
run: npm ci
85+
86+
- name: Publish canary release
87+
run: |
88+
npm exec --workspaces -- ../../packages/repo-configs/scripts/prepare-canary
89+
npx changeset publish --tag canary
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Output canary version
94+
uses: actions/github-script@v4.0.2
95+
with:
96+
script: |
97+
const paths = ['theme'].forEach((path) => {
98+
const package = require(`${process.env.GITHUB_WORKSPACE}/packages/${path}/package.json`)
99+
github.repos.createCommitStatus({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
sha: context.sha,
103+
state: 'success',
104+
context: `Published ${package.name}`,
105+
description: package.version,
106+
target_url: `https://unpkg.com/${package.name}@${package.version}/`
107+
})
108+
})

.github/workflows/release_canary.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/release_candidate.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.17.1
1+
v24

packages/repo-configs/scripts/prepare-canary

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ echo "$( jq '.version = "0.0.0"' package.json )" > package.json
55
echo -e "---\n$( jq .name package.json ): patch\n---\n\nFake entry to force publishing" > ../../.changeset/force-snapshot-release.md
66

77
cd ../../
8-
yarn changeset version --snapshot
8+
npx changeset version --snapshot

packages/theme/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"description": "A Next.js theme for building Primer documentation sites",
55
"main": "index.js",
66
"type": "module",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/primer/doctocat-nextjs.git"
10+
},
711
"scripts": {
812
"check": "tsc --noEmit",
913
"lint": "eslint '**/*.{js,ts,tsx,md,mdx}' --max-warnings=0 --config ./.eslintrc.cjs",

0 commit comments

Comments
 (0)