Skip to content

Commit 67c8c03

Browse files
authored
ci: add uppt release flow (#84)
Signed-off-by: Tierney Cyren <hello@bnb.im>
1 parent ebe784f commit 67c8c03

13 files changed

Lines changed: 146 additions & 22 deletions

File tree

.github/workflows/release.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
types: [closed]
8+
branches: [main]
9+
# this is required to trigger releases when the release PR is merged, or to rerun a release if needed
10+
workflow_dispatch:
11+
12+
permissions: {}
13+
14+
jobs:
15+
# Parse commits since the last tag, push a `release/vX.Y.Z` branch, open
16+
# or update a draft release PR, and close any superseded release PRs
17+
# (e.g. `release/v1.0.1` when the bump is now `release/v1.1.0`).
18+
pr:
19+
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write # push the `release/vX.Y.Z` branch and delete superseded ones
23+
pull-requests: write # create a release PR, update its body, close superseded PRs
24+
steps:
25+
- uses: danielroe/uppt/pr@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
packages: |
29+
aliases
30+
core
31+
fetchindex
32+
newest
33+
oldest
34+
parsefiles
35+
ranges
36+
static
37+
!opt
38+
!translate
39+
40+
# The release PR was merged: tag the squash commit, cut a GitHub release
41+
# from the PR body, and dispatch the publish workflow. The `release/v`
42+
# head-ref guard keeps regular feature-PR merges from triggering this;
43+
# the head-repo guard keeps merged fork PRs from triggering it.
44+
release:
45+
if: |
46+
github.event_name == 'pull_request'
47+
&& github.event.pull_request.merged == true
48+
&& startsWith(github.event.pull_request.head.ref, 'release/v')
49+
&& github.event.pull_request.head.repo.full_name == github.repository
50+
runs-on: ubuntu-latest
51+
concurrency:
52+
group: release-${{ github.event.pull_request.number }}
53+
cancel-in-progress: false
54+
permissions:
55+
contents: write # push the `vX.Y.Z` tag and create the GitHub release
56+
actions: write # `gh workflow run release.yml --ref vX.Y.Z` chained dispatch
57+
steps:
58+
- uses: danielroe/uppt/release@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5
59+
with:
60+
token: ${{ secrets.GITHUB_TOKEN }}
61+
packages: |
62+
aliases
63+
core
64+
fetchindex
65+
newest
66+
oldest
67+
parsefiles
68+
ranges
69+
static
70+
!opt
71+
!translate
72+
73+
# The chained dispatch from `release` lands here as a `workflow_dispatch`
74+
# event on a `vX.Y.Z` tag ref. The `pack` job installs deps, runs
75+
# `pnpm pack` (or `npm pack`), and uploads the tarball as a workflow
76+
# artifact. See "Lifecycle scripts" below for what runs where. Manual
77+
# recovery uses the same path (Run workflow -> pick a `v*` tag).
78+
pack:
79+
if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/v')
80+
runs-on: ubuntu-latest
81+
concurrency:
82+
group: pack-${{ github.ref }}
83+
cancel-in-progress: false
84+
permissions: {}
85+
outputs:
86+
files: ${{ steps.pack.outputs.files }}
87+
steps:
88+
- id: pack
89+
uses: danielroe/uppt/pack@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5
90+
with:
91+
packages: |
92+
aliases
93+
core
94+
fetchindex
95+
newest
96+
oldest
97+
parsefiles
98+
ranges
99+
static
100+
!opt
101+
!translate
102+
103+
# `publish` downloads the prebuilt tarball from the pack job's
104+
# artifact and stages it for publish.
105+
publish:
106+
if: |
107+
github.event_name == 'workflow_dispatch'
108+
&& startsWith(github.ref, 'refs/tags/v')
109+
&& needs.pack.outputs.files != '[]'
110+
needs: pack
111+
runs-on: ubuntu-latest
112+
concurrency:
113+
group: publish-${{ github.ref }}
114+
cancel-in-progress: false
115+
permissions:
116+
id-token: write # OIDC claim for npm trusted publisher
117+
environment: npm # must match the trusted-publisher entry on npmjs.com
118+
steps:
119+
- uses: danielroe/uppt/publish@7bcfb5397c37202ef882363f755423130419d28a # v0.5.5
120+
with:
121+
files: ${{ needs.pack.outputs.files }}

.github/workflows/tests-core.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ jobs:
2828
- name: Run npm install -w core
2929
run: npm install -w core
3030
- name: Run npm test -w core
31-
run: npm test -w core
32-
- name: 'Run npm run test:update and npm test -w core'
33-
run: npm run test:update && npm test -w core
31+
run: npm test -w core

aliases/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodevu/aliases",
3-
"version": "0.0.2",
3+
"version": "1.0.0",
44
"description": "available aliases for sets of Node.js versions",
55
"main": "index.js",
66
"repository": {

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodevu/core",
3-
"version": "0.3.0",
3+
"version": "1.0.0",
44
"description": "nodevu core API: comprehensive node.js version tooling",
55
"main": "index.js",
66
"scripts": {

core/util/dev/beforeEachTemplate.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const dns = require('node:dns');
2-
const { MockAgent, setGlobalDispatcher } = require('undici');
2+
const {
3+
fetch: undiciFetch,
4+
MockAgent,
5+
setGlobalDispatcher,
6+
} = require('undici');
37

48
const staticIndex = require('../../test/data/static/index.json');
59
const staticSchedule = require('../../test/data/static/schedule.json');
@@ -8,11 +12,16 @@ function beforeEachTemplate() {
812
// this fixes a bug in Node.js - it should be fixed _eventually_ and can be removed: https://github.com/nodejs/undici/issues/1248
913
dns.setDefaultResultOrder('ipv4first');
1014

11-
// this mock agent stuff isn't actually working for... some unkown reason
1215
const mockAgent = new MockAgent();
1316
mockAgent.disableNetConnect();
1417
setGlobalDispatcher(mockAgent);
1518

19+
// Node.js's built-in globalThis.fetch uses a bundled copy of undici separate from
20+
// the npm package, so setGlobalDispatcher above doesn't affect it. Replacing it here
21+
// ensures all fetch calls (including those that fall through to globalThis.fetch in
22+
// optionsParser) go through the mock dispatcher.
23+
globalThis.fetch = undiciFetch;
24+
1625
const defaultIndexMock = mockAgent.get('https://nodejs.org');
1726
defaultIndexMock
1827
.intercept({ path: '/dist/index.json' })
@@ -25,13 +34,9 @@ function beforeEachTemplate() {
2534
.intercept({ path: '/nodejs/Release/master/schedule.json' })
2635
.reply(200, staticSchedule);
2736

28-
const customIndexMock = mockAgent.get('https://bnb.im');
29-
customIndexMock
30-
.intercept({ path: '/dist/index.json' })
31-
.reply(200, staticIndex);
32-
33-
const customScheduleMock = mockAgent.get('https://bnb.im');
34-
customScheduleMock
37+
const customMock = mockAgent.get('https://bnb.im');
38+
customMock.intercept({ path: '/dist/index.json' }).reply(200, staticIndex);
39+
customMock
3540
.intercept({ path: '/dist/schedule.json' })
3641
.reply(200, staticSchedule);
3742
}

fetchindex/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodevu/fetchindex",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "A tool that fetches the /dist/index.json file from the Node.js website.",
55
"main": "index.js",
66
"files": ["index.js", "LICENSE"],

newest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodevu/newest",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "a module that returns the newest lts or security release of the release line passed.",
55
"main": "index.js",
66
"files": ["index.js", "LICENSE"],

oldest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodevu/oldest",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "a module that returns the oldest lts or security release of the release line passed.",
55
"main": "index.js",
66
"files": ["index.js", "LICENSE"],

opt/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodevu/opt",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "internal options parser for @nodevu packages.",
55
"main": "index.js",
66
"files": ["index.js", "LICENSE"],

parsefiles/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodevu/parsefiles",
3-
"version": "0.0.3",
3+
"version": "1.0.0",
44
"description": "parse the files identifiers from Node.js",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)