Skip to content

Commit 182f4ab

Browse files
Add support for automated release using GitHub Actions (#689)
### Description Adds the release workflow to use a fully automated release process, also removes the old publish workflow ### Testing - [ ] This change adds test coverage for new/changed/fixed functionality ### Checklist - [ ] I have added documentation for new/changed functionality in this PR or in auth0.com/docs - [ ] All active GitHub checks for tests, formatting, and security are passing - [ ] The correct base branch is being used, if not the default branch
1 parent 0518369 commit 182f4ab

File tree

8 files changed

+291
-114
lines changed

8 files changed

+291
-114
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Return a boolean indicating if the version contains prerelease identifiers
2+
3+
#
4+
# Returns a simple true/false boolean indicating whether the version indicates it's a prerelease or not.
5+
#
6+
# TODO: Remove once the common repo is public.
7+
#
8+
9+
inputs:
10+
version:
11+
required: true
12+
13+
outputs:
14+
prerelease:
15+
value: ${{ steps.get_prerelease.outputs.PRERELEASE }}
16+
17+
runs:
18+
using: composite
19+
20+
steps:
21+
- id: get_prerelease
22+
shell: bash
23+
run: |
24+
if [[ "${VERSION}" == *"beta"* || "${VERSION}" == *"alpha"* ]]; then
25+
echo "PRERELEASE=true" >> $GITHUB_OUTPUT
26+
else
27+
echo "PRERELEASE=false" >> $GITHUB_OUTPUT
28+
fi
29+
env:
30+
VERSION: ${{ inputs.version }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Return the release notes extracted from the PR body
2+
3+
#
4+
# 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.
5+
#
6+
# TODO: Remove once the common repo is public.
7+
#
8+
inputs:
9+
version :
10+
required: true
11+
repo_name:
12+
required: false
13+
repo_owner:
14+
required: true
15+
token:
16+
required: true
17+
18+
runs:
19+
using: composite
20+
21+
steps:
22+
- uses: actions/github-script@v7
23+
id: get_release_notes
24+
with:
25+
result-encoding: string
26+
script: |
27+
const { data: pulls } = await github.rest.pulls.list({
28+
owner: process.env.REPO_OWNER,
29+
repo: process.env.REPO_NAME,
30+
state: 'all',
31+
head: `${process.env.REPO_OWNER}:release/${process.env.VERSION}`,
32+
});
33+
core.exportVariable('RELEASE_NOTES', pulls[0].body)
34+
env:
35+
GITHUB_TOKEN: ${{ inputs.token }}
36+
REPO_OWNER: ${{ inputs.repo_owner }}
37+
REPO_NAME: ${{ inputs.repo_name }}
38+
VERSION: ${{ inputs.version }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Return the version extracted from the branch name
2+
3+
#
4+
# Returns the version from the .version file.
5+
#
6+
# TODO: Remove once the common repo is public.
7+
#
8+
9+
outputs:
10+
version:
11+
value: ${{ steps.get_version.outputs.VERSION }}
12+
13+
runs:
14+
using: composite
15+
16+
steps:
17+
- id: get_version
18+
shell: bash
19+
run: |
20+
VERSION=$(head -1 .version)
21+
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish release to package manager
2+
3+
inputs:
4+
node-version:
5+
required: true
6+
npm-token:
7+
required: true
8+
version:
9+
required: true
10+
11+
runs:
12+
using: composite
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ inputs.node-version }}
22+
cache: 'npm'
23+
registry-url: 'https://registry.npmjs.org'
24+
25+
- name: Build package
26+
uses: ./.github/actions/build
27+
with:
28+
node: ${{ inputs.node-version }}
29+
30+
- name: Publish release to NPM
31+
shell: bash
32+
run: |
33+
if [[ "${VERSION}" == *"beta"* ]]; then
34+
TAG="beta"
35+
elif [[ "${VERSION}" == *"alpha"* ]]; then
36+
TAG="alpha"
37+
else
38+
TAG="latest"
39+
fi
40+
npm publish --provenance --tag $TAG
41+
env:
42+
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
43+
VERSION: ${{ inputs.version }}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create a GitHub release
2+
3+
#
4+
# Creates a GitHub release with the given version.
5+
#
6+
# TODO: Remove once the common repo is public.
7+
#
8+
9+
inputs:
10+
token:
11+
required: true
12+
files:
13+
required: false
14+
name:
15+
required: true
16+
body:
17+
required: true
18+
tag:
19+
required: true
20+
commit:
21+
required: true
22+
draft:
23+
default: false
24+
required: false
25+
prerelease:
26+
default: false
27+
required: false
28+
fail_on_unmatched_files:
29+
default: true
30+
required: false
31+
32+
runs:
33+
using: composite
34+
35+
steps:
36+
- uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
37+
with:
38+
body: ${{ inputs.body }}
39+
name: ${{ inputs.name }}
40+
tag_name: ${{ inputs.tag }}
41+
target_commitish: ${{ inputs.commit }}
42+
draft: ${{ inputs.draft }}
43+
prerelease: ${{ inputs.prerelease }}
44+
fail_on_unmatched_files: ${{ inputs.fail_on_unmatched_files }}
45+
files: ${{ inputs.files }}
46+
env:
47+
GITHUB_TOKEN: ${{ inputs.token }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Return a boolean indicating if a tag already exists for the repository
2+
3+
#
4+
# Returns a simple true/false boolean indicating whether the tag exists or not.
5+
#
6+
# TODO: Remove once the common repo is public.
7+
#
8+
9+
inputs:
10+
token:
11+
required: true
12+
tag:
13+
required: true
14+
15+
outputs:
16+
exists:
17+
description: 'Whether the tag exists or not'
18+
value: ${{ steps.tag-exists.outputs.EXISTS }}
19+
20+
runs:
21+
using: composite
22+
23+
steps:
24+
- id: check
25+
shell: bash
26+
run: |
27+
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/${TAG_NAME}"
28+
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s -H "Authorization: token ${GITHUB_TOKEN}")
29+
if [ "$http_status_code" -ne "404" ] ; then
30+
echo "EXISTS=true" >> $GITHUB_OUTPUT
31+
else
32+
echo "EXISTS=false" >> $GITHUB_OUTPUT
33+
fi
34+
env:
35+
TAG_NAME: ${{ inputs.tag }}
36+
GITHUB_TOKEN: ${{ inputs.token }}

.github/workflows/publish.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)