Skip to content

Commit 686295d

Browse files
authored
build: support OIDC for npmjs publishing (#1480)
* ci: manually trigger publishing in release.yml * refactor: replace yarn with npm * ci: fix npm publish command * Revert "ci: manually trigger publishing in release.yml" This reverts commit 9ddef07. * ci: temporarly add publish step in test workflow * build: apply suggested npm fix to package.json * ci: reset test workflow to original * ci: temporarly trigger release.yml workflow on pull requests * chore: bump & enforce npm version * chore: add packageManager field in pacakge.json * ci: factor setting up the repo in a common composite action * ci: remove checkout from common setup * ci: fix call to custom composite setup * ci: manually install npm in setup * ci: restore original release workflow
1 parent 9928b92 commit 686295d

17 files changed

Lines changed: 7910 additions & 4944 deletions

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// "forwardPorts": [],
2121

2222
// Use 'postCreateCommand' to run commands after the container is created.
23-
"postCreateCommand": "yarn install",
23+
"postCreateCommand": "npm install",
2424

2525
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
2626
"remoteUser": "node"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Node & npm setup
2+
author: Clément Chanchevrier @cchanche
3+
description: 'Common job setup for npm managed repo'
4+
5+
runs:
6+
using: 'composite'
7+
steps:
8+
- name: Setup Node.js
9+
uses: actions/setup-node@v6
10+
with:
11+
node-version: 20
12+
13+
- name: Install npm
14+
shell: bash
15+
run: npm install -g [email protected]
16+
17+
- name: Install dependencies
18+
shell: bash
19+
run: npm ci

.github/no-unstaged-files.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
if [[ "$(git status --porcelain)" != "" ]]; then
44
git status
5-
echo "::error::💥 Unstaged changes detected. Locally try running: yarn prettier && yarn lint --fix && yarn build"
5+
echo "::error::💥 Unstaged changes detected. Locally try running: npm run prettier && npm run lint --fix && npm run build"
66
exit 1
77
fi

.github/workflows/action-build.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,12 @@ jobs:
2121
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'release-drafter/release-drafter'
2222
runs-on: ubuntu-latest
2323
steps:
24-
- name: Checkout
25-
uses: actions/checkout@v4
24+
- uses: actions/checkout@v6
2625
with:
2726
ref: ${{ github.event.pull_request.head.ref }}
27+
- uses: ./.github/actions/common-setup
2828

29-
- uses: actions/setup-node@v3
30-
with:
31-
node-version: '20'
32-
cache: 'yarn'
33-
34-
- run: yarn install --frozen-lockfile
35-
36-
- run: yarn build
29+
- run: npm run build
3730

3831
- name: Commit and push if needed
3932
run: |

.github/workflows/release.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Release
2+
23
on:
34
push:
45
tags:
@@ -16,26 +17,16 @@ jobs:
1617
if: github.repository == 'release-drafter/release-drafter'
1718
runs-on: ubuntu-latest
1819
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v3
20+
- uses: actions/checkout@v6
2121
with:
2222
fetch-depth: 0
23+
- uses: ./.github/actions/common-setup
2324

24-
- name: Setup Node
25-
uses: actions/setup-node@v3
26-
with:
27-
node-version: '20'
28-
cache: yarn
29-
registry-url: https://registry.npmjs.org
30-
31-
- name: yarn install
32-
run: yarn install --frozen-lockfile
33-
34-
- name: yarn test
35-
run: yarn test
25+
- name: test
26+
run: npm run test
3627

37-
- name: 'yarn publish'
38-
run: yarn publish --access public
28+
- name: publish
29+
run: npm publish # Publishes to npmjs, using package.json's version
3930

4031
- name: version
4132
id: version

.github/workflows/tests.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ on:
66
- master
77
pull_request:
88

9+
permissions:
10+
id-token: write
11+
contents: write
12+
913
env:
1014
HUSKY: '0'
1115

1216
jobs:
1317
build:
1418
runs-on: ubuntu-latest
1519
steps:
16-
- uses: actions/checkout@v3
17-
- uses: actions/setup-node@v3
18-
with:
19-
node-version: '20'
20-
cache: 'yarn'
21-
- run: yarn install --frozen-lockfile
22-
- run: yarn test
23-
- run: yarn lint --fix
24-
- run: yarn prettier
25-
- run: yarn build
20+
- uses: actions/checkout@v6
21+
- uses: ./.github/actions/common-setup
22+
- run: npm run test
23+
- run: npm run lint --fix
24+
- run: npm run prettier
25+
- run: npm run build
2626
- name: correct vercel/ncc crlf output
2727
run: sed -i 's/\x0D$//' ./dist/index.js
2828
- name: check for unstaged files

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ npm-debug.log
55
coverage
66
now.json
77
docker-compose-logs
8-
package-lock.json
8+
!package-lock.json
9+
yarn.lock
910
dist/static/
1011
dist/views/
1112

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
[ ! -x "$(command -v yarn)" ] || yarn lint-staged
4+
[ ! -x "$(command -v npm)" ] || npx lint-staged

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Contributing
1+
# Contributing
22

33
[fork]: https://github.com/release-drafter/release-drafter/fork
44
[pr]: /compare
@@ -12,16 +12,16 @@ Please note that this project is released with a [Contributor Code of Conduct][c
1212
## Submitting a pull request
1313

1414
1. [Fork][fork] and clone the repository
15-
1. Configure and install the dependencies: `yarn install`
16-
1. Make sure the tests pass on your machine: `yarn test`, note: these tests also apply the linter, so no need to lint separately
17-
1. Create a new branch: `git checkout -b my-branch-name`
18-
1. Make your change, add tests, build with `yarn prettier && yarn lint --fix && yarn build` and make sure the tests still pass
19-
1. Push to your fork and [submit a pull request][pr]
20-
1. Give yourself a high five, and wait for your pull request to be reviewed and merged.
15+
2. Configure and install the dependencies: `npm install`
16+
3. Make sure the tests pass on your machine: `npm run test`, note: these tests also apply the linter, so no need to lint separately
17+
4. Create a new branch: `git checkout -b my-branch-name`
18+
5. Make your change, add tests, build with `npm run prettier && npm run lint --fix && npm run build` and make sure the tests still pass
19+
6. Push to your fork and [submit a pull request][pr]
20+
7. Give yourself a high five, and wait for your pull request to be reviewed and merged.
2121

2222
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
2323

24-
- Follow the [style guide][style] which is using standard. Any linting errors should be shown when running `yarn test`
24+
- Follow the [style guide][style] which is using standard. Any linting errors should be shown when running `npm run test`
2525
- Write and update tests.
2626
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
2727
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

0 commit comments

Comments
 (0)