From f51f226522ec75a0613a07a4efc8f78938030c45 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 8 Apr 2024 11:09:48 +0200 Subject: [PATCH] automate releases (#3052) * automate releases Signed-off-by: Matteo Collina * fixup Signed-off-by: Matteo Collina * drop publish-undici-types job Signed-off-by: Matteo Collina * fixup Signed-off-by: Matteo Collina * fixup Signed-off-by: Matteo Collina * fixup Signed-off-by: Matteo Collina * fixup Signed-off-by: Matteo Collina --------- Signed-off-by: Matteo Collina --- .github/workflows/publish-undici-types.yml | 26 ------- .github/workflows/release.yml | 86 ++++++++++++++++++++++ CONTRIBUTING.md | 6 ++ 3 files changed, 92 insertions(+), 26 deletions(-) delete mode 100644 .github/workflows/publish-undici-types.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/publish-undici-types.yml b/.github/workflows/publish-undici-types.yml deleted file mode 100644 index 5ebbce01505..00000000000 --- a/.github/workflows/publish-undici-types.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Publish undici-types - -on: - push: - tags: - - 'v*' - workflow_dispatch: - -permissions: - contents: read - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: lts/* - registry-url: 'https://registry.npmjs.org' - - run: npm install - - run: node scripts/generate-undici-types-package-json.js - - run: npm publish - working-directory: './types' - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000..5e44736e2bb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: Publish package to npm + +permissions: + contents: read + +on: + workflow_dispatch: + inputs: + version: + description: 'The version number to release (has priority over release_type)' + type: string + release_type: + description: Type of release + type: choice + default: patch + options: + - patch + - minor + - major + +jobs: + release: + runs-on: ubuntu-latest + + permissions: + contents: write + id-token: write + + environment: release + + outputs: + version: ${{ steps.bump.outputs.version }} + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + - run: npm install -g npm@latest + - run: npm install + - name: Git Config + run: | + git config --global user.email "hello@matteocollina.com" + git config --global user.name "Matteo Collina" + - name: Change version number and push + id: bump + run: | + npm version ${{ inputs.version || inputs.release_type }} --git-tag-version=false + VERSION=`jq -r ".version" package.json` + echo "version=$VERSION" >> $GITHUB_OUTPUT + git add -u + git commit -m "Bumped v$VERSION" + git push origin HEAD:main + - run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - run: node scripts/generate-undici-types-package-json.js + - run: npm publish --provenance + working-directory: './types' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + releasenotes: + runs-on: ubuntu-latest + needs: release + + permissions: + contents: write + + env: + VERSION: ${{ needs.release.outputs.version }} + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + - name: 'Install release-notes' + run: npm i @matteo.collina/release-notes -g + - name: 'Create release notes' + run: | + NOTES=`release-notes -a ${{ secrets.GITHUB_TOKEN }} -t v$VERSION -r undici -o nodejs` + echo "# Released version $VERSION :rocket:" >> $GITHUB_STEP_SUMMARY + echo "url: $NOTES" >> $GITHUB_STEP_SUMMARY diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a910263bd1..79d226cd7fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,6 +5,7 @@ * [Lint](#lint) * [Test](#test) * [Coverage](#coverage) + * [Releases](#releases) * [Update `WPTs`](#update-wpts) * [Building for externally shared node builtins](#external-builds) * [Developer's Certificate of Origin 1.1](#developers-certificate-of-origin) @@ -166,6 +167,11 @@ npm run test npm run coverage ``` + +### Issuing Releases + +Use the release github action. + ### Building for externally shared node builtins