forked from nodejs/undici
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'automated-release' into mweberxyz-main
- Loading branch information
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Create release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- package.json | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check-release-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release-version: ${{ steps.set-release-version.outputs.result }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/github-script@v7 | ||
id: set-release-version | ||
with: | ||
result-encoding: string | ||
script: | | ||
const version = require("./package.json").version | ||
const { data: releases } = await github.rest.repos.listReleases({ | ||
owner, | ||
repo | ||
}) | ||
if(version !== releases[0].title) { | ||
return version | ||
} | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: check-release-version | ||
if: ${{ needs.check-release-version.outputs.release-version }} | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
environment: release | ||
|
||
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: Create NPM release | ||
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 }} | ||
- name: Create GitHub release | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const defaultBranch = "${{ github.event.repository.default_branch }}" | ||
const { owner, repo } = context.repo | ||
const version = "v${{ steps.bump.outputs.version }}" | ||
const { data: releases } = await github.rest.repos.listReleases({ | ||
owner, | ||
repo | ||
}) | ||
const { data: { body } } = await github.rest.repos.generateReleaseNotes({ | ||
owner, | ||
repo, | ||
tag_name: version, | ||
target_commitish: defaultBranch, | ||
previous_tag_name: releases[0]?.tag_name | ||
}); | ||
await github.rest.repos.createRelease({ | ||
owner, | ||
repo, | ||
tag_name: version, | ||
target_commitish: defaultBranch, | ||
name: version, | ||
body, | ||
draft: false, | ||
prerelease: false, | ||
generate_release_notes: false | ||
}); |