Skip to content

Commit f31402c

Browse files
Update automated release process to latest version (#555)
1 parent 22212bc commit f31402c

File tree

4 files changed

+103
-69
lines changed

4 files changed

+103
-69
lines changed

.github/actions/get-release-notes/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Return the release notes extracted from the PR body
1+
name: Return the release notes extracted from the body of the PR associated with the release.
22

33
#
44
# Returns the release notes from the content of a pull request linked to a release branch. It expects the branch name to be in the format release/vX.Y.Z, release/X.Y.Z, release/vX.Y.Z-beta.N. etc.

.github/actions/publish-package/action.yml renamed to .github/actions/npm-publish/action.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish release to package manager
1+
name: Publish release to npm
22

33
inputs:
44
node-version:
@@ -7,6 +7,8 @@ inputs:
77
required: true
88
version:
99
required: true
10+
require-build:
11+
default: true
1012
release-directory:
1113
default: './'
1214

@@ -24,10 +26,14 @@ runs:
2426
cache: 'npm'
2527
registry-url: 'https://registry.npmjs.org'
2628

29+
- name: Install dependencies
30+
shell: bash
31+
run: npm ci --include=dev
32+
2733
- name: Build package
28-
uses: ./.github/actions/build
29-
with:
30-
node: ${{ inputs.node-version }}
34+
if: inputs.require-build == 'true'
35+
shell: bash
36+
run: npm run build
3137

3238
- name: Publish release to NPM
3339
shell: bash

.github/workflows/npm-release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Create npm and GitHub Release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
node-version:
7+
required: true
8+
type: string
9+
require-build:
10+
default: true
11+
type: string
12+
release-directory:
13+
default: './'
14+
type: string
15+
secrets:
16+
github-token:
17+
required: true
18+
npm-token:
19+
required: true
20+
21+
jobs:
22+
release:
23+
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/'))
24+
runs-on: ubuntu-latest
25+
environment: release
26+
27+
steps:
28+
# Checkout the code
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
# Get the version from the branch name
34+
- id: get_version
35+
uses: ./get-version
36+
37+
# Get the prerelease flag from the branch name
38+
- id: get_prerelease
39+
uses: ./get-prerelease
40+
with:
41+
version: ${{ steps.get_version.outputs.version }}
42+
43+
# Get the release notes
44+
- id: get_release_notes
45+
uses: ./get-release-notes
46+
with:
47+
token: ${{ secrets.github-token }}
48+
version: ${{ steps.get_version.outputs.version }}
49+
repo_owner: ${{ github.repository_owner }}
50+
repo_name: ${{ github.event.repository.name }}
51+
52+
# Check if the tag already exists
53+
- id: tag_exists
54+
uses: ./tag-exists
55+
with:
56+
tag: ${{ steps.get_version.outputs.version }}
57+
token: ${{ secrets.github-token }}
58+
59+
# If the tag already exists, exit with an error
60+
- if: steps.tag_exists.outputs.exists == 'true'
61+
run: exit 1
62+
63+
# Publish the release to our package manager
64+
- uses: ./npm-publish
65+
with:
66+
node-version: ${{ inputs.node-version }}
67+
require-build: ${{ inputs.require-build }}
68+
version: ${{ steps.get_version.outputs.version }}
69+
npm-token: ${{ secrets.npm-token }}
70+
release-directory: ${{ inputs.release-directory }}
71+
72+
# Create a release for the tag
73+
- uses: ./release-create
74+
with:
75+
token: ${{ secrets.github-token }}
76+
name: ${{ steps.get_version.outputs.version }}
77+
body: ${{ steps.get_release_notes.outputs.release-notes }}
78+
tag: ${{ steps.get_version.outputs.version }}
79+
commit: ${{ github.sha }}
80+
prerelease: ${{ steps.get_prerelease.outputs.prerelease }}

.github/workflows/release.yml

Lines changed: 12 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create GitHub Release
1+
name: Create npm and GitHub Release
22

33
on:
44
pull_request:
@@ -10,69 +10,17 @@ permissions:
1010
contents: write
1111
id-token: write # For publishing to npm using --provenance
1212

13-
env:
14-
NODE_VERSION: 18
15-
16-
### TODO: Replace instances of './.github/actions/' w/ `auth0/dx-sdk-actions/` and append `@latest` after the common `dx-sdk-actions` repo is made public.
17-
### TODO: Also remove `get-prerelease`, `get-version`, `release-create`, `tag-create` and `tag-exists` actions from this repo's .github/actions folder once the repo is public.
13+
### TODO: Replace instances of './.github/workflows/' w/ `auth0/dx-sdk-actions/workflows/` and append `@latest` after the common `dx-sdk-actions` repo is made public.
14+
### TODO: Also remove `get-prerelease`, `get-release-notes`, `get-version`, `npm-publish`, `release-create`, and `tag-exists` actions from this repo's .github/actions folder once the repo is public.
15+
### TODO: Also remove `npm-release` workflow from this repo's .github/workflows folder once the repo is public.
1816

1917
jobs:
2018
release:
21-
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/'))
22-
runs-on: ubuntu-latest
23-
environment: release
24-
25-
steps:
26-
# Checkout the code
27-
- uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 0
30-
31-
# Get the version from the branch name
32-
- id: get_version
33-
uses: ./.github/actions/get-version
34-
35-
# Get the prerelease flag from the branch name
36-
- id: get_prerelease
37-
uses: ./.github/actions/get-prerelease
38-
with:
39-
version: ${{ steps.get_version.outputs.version }}
40-
41-
# Get the release notes
42-
# This will expose the release notes as env.RELEASE_NOTES
43-
- id: get_release_notes
44-
uses: ./.github/actions/get-release-notes
45-
with:
46-
token: ${{ secrets.GITHUB_TOKEN }}
47-
version: ${{ steps.get_version.outputs.version }}
48-
repo_owner: ${{ github.repository_owner }}
49-
repo_name: ${{ github.event.repository.name }}
50-
51-
# Check if the tag already exists
52-
- id: tag_exists
53-
uses: ./.github/actions/tag-exists
54-
with:
55-
tag: ${{ steps.get_version.outputs.version }}
56-
token: ${{ secrets.GITHUB_TOKEN }}
57-
58-
# If the tag already exists, exit with an error
59-
- if: steps.tag_exists.outputs.exists == 'true'
60-
run: exit 1
61-
62-
# Publish the release to our package manager
63-
- uses: ./.github/actions/publish-package
64-
with:
65-
node-version: ${{ env.NODE_VERSION }}
66-
version: ${{ steps.get_version.outputs.version }}
67-
npm-token: ${{ secrets.NPM_TOKEN }}
68-
release-directory: './dist/auth0-angular'
69-
70-
# Create a release for the tag
71-
- uses: ./.github/actions/release-create
72-
with:
73-
token: ${{ secrets.GITHUB_TOKEN }}
74-
name: ${{ steps.get_version.outputs.version }}
75-
body: ${{ steps.get_release_notes.outputs.release-notes }}
76-
tag: ${{ steps.get_version.outputs.version }}
77-
commit: ${{ github.sha }}
78-
prerelease: ${{ steps.get_prerelease.outputs.prerelease }}
19+
uses: ./.github/workflows/npm-release.yml
20+
with:
21+
node-version: 18
22+
require-build: true
23+
release-directory: './dist/auth0-angular'
24+
secrets:
25+
npm-token: ${{ secrets.NPM_TOKEN }}
26+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)