Skip to content

Commit a38892c

Browse files
jonrohanCopilot
andauthored
Combine release workflows for npm token change (#787)
* Combine release workflows for npm token change * Add repo * Update package-lock * Update theme/package.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update node version * Update node and package-lock * Add permissions --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b6602cd commit a38892c

File tree

6 files changed

+789
-2524
lines changed

6 files changed

+789
-2524
lines changed

.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: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
name: Release
22
on:
33
push:
4-
branches:
5-
- 'main'
6-
- 'next_major'
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
permissions:
10+
id-token: write # Required for OIDC
11+
contents: read
12+
checks: write
13+
statuses: write
14+
715
jobs:
8-
release:
9-
name: Final
10-
if: ${{ github.repository == 'primer/doctocat' }}
16+
release-main:
17+
name: Main
18+
if: ${{ github.repository == 'primer/doctocat' && github.ref_name == 'main' }}
1119

1220
runs-on: ubuntu-latest
1321
steps:
@@ -21,19 +29,64 @@ jobs:
2129
- name: Set up Node.js
2230
uses: actions/setup-node@v6
2331
with:
24-
node-version: 18
32+
node-version: 24
2533
cache: 'npm'
2634

2735
- name: Install dependencies
2836
run: npm ci
2937

3038
- name: Create release pull request or publish to npm
3139
id: changesets
32-
uses: changesets/action@master
40+
uses: changesets/action@v1
3341
with:
3442
title: Release Tracking
3543
# This expects you to have a script called release which does a build for your packages and calls changeset publish
3644
publish: npm run release
3745
env:
3846
GITHUB_TOKEN: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
39-
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
47+
48+
release-canary:
49+
name: Canary
50+
if: ${{ github.repository == 'primer/doctocat' && github.ref_name != 'main' && github.ref_name != 'changeset-release/main' }}
51+
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
with:
57+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
58+
fetch-depth: 0
59+
60+
- name: Set up Node.js
61+
uses: actions/setup-node@v6
62+
with:
63+
node-version: 24
64+
cache: 'npm'
65+
66+
- name: Install dependencies
67+
run: npm ci
68+
69+
- name: Publish canary version
70+
run: |
71+
echo "$( jq '.version = "0.0.0"' package.json )" > package.json
72+
echo -e "---\n'@primer/gatsby-theme-doctocat': patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md
73+
rm -f .changeset/pre.json
74+
npx changeset version --snapshot
75+
npx changeset publish --tag canary
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Output canary version number
80+
uses: actions/github-script@v8
81+
with:
82+
script: |
83+
const package = require(`${process.env.GITHUB_WORKSPACE}/theme/package.json`)
84+
github.rest.repos.createCommitStatus({
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
sha: context.sha,
88+
state: 'success',
89+
context: `Published ${package.name}`,
90+
description: package.version,
91+
target_url: `https://unpkg.com/${package.name}@${package.version}/`
92+
})

.github/workflows/release_canary.yml

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

.nvmrc

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

0 commit comments

Comments
 (0)