Skip to content

Commit 96d067a

Browse files
authored
Merge branch 'main' into boronine-patch-1
2 parents 00f26a5 + 3113d95 commit 96d067a

3 files changed

Lines changed: 54 additions & 56 deletions

File tree

.github/workflows/nodeci.yml

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,11 @@ jobs:
1818
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
1919
node-version: [ 18.x, 20.x, 22.x ]
2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v6
2222
- name: Use Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v4
23+
uses: actions/setup-node@v6
2424
with:
2525
node-version: ${{ matrix.node-version }}
2626
cache: 'npm'
2727
- run: npm ci
2828
- run: npm run build
29-
- name: Store artifacts
30-
if: matrix.node-version == '20.x'
31-
uses: actions/upload-artifact@v4
32-
with:
33-
name: build-assets
34-
path: assets/
35-
release:
36-
runs-on: ubuntu-latest
37-
# Wait for build because we need the build artifacts here
38-
needs: [ build ]
39-
# Only run when pushing to main branch
40-
if: github.event_name != 'pull_request'
41-
steps:
42-
- uses: actions/checkout@v4
43-
# Download artifact instead of rebuilding
44-
- uses: actions/download-artifact@v4
45-
with:
46-
name: build-assets
47-
path: assets/
48-
- run: echo "HSLUV_VERSION=$(cat assets/VERSION)" >> ${{ github.env }}
49-
- uses: rickstaa/action-create-tag@v1
50-
id: create-tag
51-
# When tag already exists, do not fail the job
52-
continue-on-error: true
53-
with:
54-
tag: "v${{ env.HSLUV_VERSION }}"
55-
- uses: ncipollo/release-action@v1
56-
if: ${{ steps.create-tag.outcome == 'success' }}
57-
with:
58-
artifacts: assets/hsluv-${{ env.HSLUV_VERSION }}.min.js
59-
tag: v${{ env.HSLUV_VERSION }}
60-
draft: true
61-
omitBody: true
62-
prerelease: ${{ contains(env.HSLUV_VERSION, 'rc') }}
63-
bodyFile: "body.md"
64-
token: ${{ secrets.GITHUB_TOKEN }}
65-
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
66-
- uses: actions/setup-node@v4
67-
if: ${{ steps.create-tag.outcome == 'success' }}
68-
with:
69-
node-version: '22.x'
70-
registry-url: 'https://registry.npmjs.org'
71-
- run: npm publish ./assets/hsluv-${{ env.HSLUV_VERSION }}.tgz --tag rc
72-
if: ${{ steps.create-tag.outcome == 'success' && contains(env.HSLUV_VERSION, 'rc') }}
73-
env:
74-
NODE_AUTH_TOKEN: ${{ secrets.HSLUV_NPM_AUTOMATION_TOKEN }}
75-
- run: npm publish ./assets/hsluv-${{ env.HSLUV_VERSION }}.tgz
76-
if: ${{ steps.create-tag.outcome == 'success' && !contains(env.HSLUV_VERSION, 'rc') }}
77-
env:
78-
NODE_AUTH_TOKEN: ${{ secrets.HSLUV_NPM_AUTOMATION_TOKEN }}

.github/workflows/npm-publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
- name: Use Node.js
18+
uses: actions/setup-node@v6
19+
with:
20+
node-version: 24.x
21+
registry-url: "https://registry.npmjs.org"
22+
- run: npm ci
23+
- name: Check release tag matches package version
24+
if: github.event_name == 'release'
25+
run: |
26+
package_version="$(node -p "require('./package.json').version")"
27+
release_version="${GITHUB_REF_NAME#v}"
28+
if [ "$package_version" != "$release_version" ]; then
29+
echo "Release tag ${GITHUB_REF_NAME} does not match package.json version ${package_version}"
30+
exit 1
31+
fi
32+
- run: npm run build
33+
- name: Publish to npm
34+
run: |
35+
package_version="$(node -p "require('./package.json').version")"
36+
tarball="./assets/hsluv-${package_version}.tgz"
37+
if [[ "$package_version" =~ -([a-zA-Z]+) ]]; then
38+
tag="${BASH_REMATCH[1]}"
39+
echo "Publishing prerelease with dist-tag: $tag"
40+
npm publish "$tarball" --provenance --access public --tag "$tag"
41+
else
42+
echo "Publishing stable release"
43+
npm publish "$tarball" --provenance --access public
44+
fi

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,14 @@ Also available for [Stylus](http://stylus-lang.com/). See [here](https://github.
7878

7979
## Development
8080

81-
Our [GitHub Actions workflow](https://github.com/hsluv/hsluv-javascript/blob/main/.github/workflows/nodeci.yml)
82-
will build and test every push and PR to the `main` branch. When a `main` branch receives a commit that
83-
updates the project version in `package.json`, the workflow will tag the commit, create a draft release
84-
on GitHub and publish the npm package. Mark your versions with the `-rc` suffix to create pre-releases.
81+
Our [Node.js CI workflow](https://github.com/hsluv/hsluv-javascript/blob/main/.github/workflows/nodeci.yml)
82+
will build and test every push and PR to the `main` branch.
83+
84+
To publish a release, configure npm trusted publishing for the `hsluv/hsluv-javascript` repository and
85+
`npm-publish.yml` workflow, then create a GitHub Release. The release tag must match the version in
86+
`package.json`. The [Publish to npm workflow](https://github.com/hsluv/hsluv-javascript/blob/main/.github/workflows/npm-publish.yml)
87+
will build the package and publish it to npm with provenance. Prerelease versions (for example `1.2.3-rc.1`)
88+
are automatically published with the matching npm dist-tag.
8589

8690
## Changelog
8791

0 commit comments

Comments
 (0)