Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated automated release to support manual trigger #1212

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/actions/get-release-notes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Return the release notes extracted from the PR body

#
# 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.
#
# TODO: Remove once the common repo is public.
#
inputs:
version :
required: true
repo_name:
required: false
repo_owner:
required: true
token:
required: true

runs:
using: composite

steps:
- uses: actions/github-script@v7
id: get_release_notes
with:
result-encoding: string
script: |
const { data: pulls } = await github.rest.pulls.list({
owner: process.env.REPO_OWNER,
repo: process.env.REPO_NAME,
state: 'all',
head: `${process.env.REPO_OWNER}:release/${process.env.VERSION}`,
});
core.exportVariable('RELEASE_NOTES', pulls[0].body)
env:
GITHUB_TOKEN: ${{ inputs.token }}
REPO_OWNER: ${{ inputs.repo_owner }}
REPO_NAME: ${{ inputs.repo_name }}
VERSION: ${{ inputs.version }}
6 changes: 2 additions & 4 deletions .github/actions/get-version/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Return the version extracted from the branch name

#
# Returns the version from a branch name of a pull request. 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.
# Returns the version from the .version file.
#
# TODO: Remove once the common repo is public.
#
Expand All @@ -17,7 +17,5 @@ runs:
- id: get_version
shell: bash
run: |
VERSION=$(echo ${BRANCH_NAME} | sed -r 's#release/+##g')
VERSION=$(head -1 .version)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
33 changes: 0 additions & 33 deletions .github/actions/tag-create/action.yml

This file was deleted.

21 changes: 13 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
types:
- closed
workflow_dispatch:

permissions:
contents: write
Expand All @@ -16,7 +17,7 @@ env:

jobs:
release:
if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')
if: github.event_name == 'workflow_dispatch'
Copy link
Member Author

@frederikprijck frederikprijck Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporarily removing the automated trigger on PR close, will bring back one manual trigger has been verified. But if we keep this trigger, if everything works as expected we can not even get to testing the manual trigger.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add back the PR merge trigger now to verify that it works once the release PR is merged?

Copy link
Member Author

@frederikprijck frederikprijck Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I was thinking to do a manual release. Then bring it back. Else we have no way to test the manual trigger.

We can then use the automated to cut a release for Auth0-React to include the latest SPA-JS.

runs-on: ubuntu-latest
environment: release

Expand All @@ -35,6 +36,16 @@ jobs:
uses: ./.github/actions/get-prerelease
with:
version: ${{ steps.get_version.outputs.version }}

# Get the release notes
# This will expose the release notes as env.RELEASE_NOTES
- id: get_release_notes
uses: ./.github/actions/get-release-notes
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ steps.get_version.outputs.version }}
repo_owner: ${{ github.repository_owner }}
repo_name: ${{ github.event.repository.name }}

# Check if the tag already exists
- id: tag_exists
Expand All @@ -53,18 +64,12 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
npm-token: ${{ secrets.NPM_TOKEN }}

# Create a tag for the release
- uses: ./.github/actions/tag-create
with:
tag: ${{ steps.get_version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}

# Create a release for the tag
- uses: ./.github/actions/release-create
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.get_version.outputs.version }}
body: ${{ github.event.pull_request.body }}
body: ${{ env.RELEASE_NOTES }}
tag: ${{ steps.get_version.outputs.version }}
commit: ${{ github.sha }}
prerelease: ${{ steps.get_prerelease.outputs.prerelease }}
11 changes: 8 additions & 3 deletions .shiprc
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"files": {
"src/version.ts": [],
"README.md": ["{MAJOR}.{MINOR}"],
"FAQ.md": ["{MAJOR}.{MINOR}.{PATCH}"]
".version": [],
"README.md": [
"{MAJOR}.{MINOR}"
],
"FAQ.md": [
"{MAJOR}.{MINOR}.{PATCH}"
]
},
"postbump": "npm run docs"
}
}
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v2.1.2