-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add automated release workflow #313
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1830a66
Add automated release workflow
frederikprijck c92586d
Remove existing publish workflow
frederikprijck d192f14
fix
frederikprijck d639996
Update .github/actions/nuget-publish/action.yml
frederikprijck c7fcdec
Add shiprc files
frederikprijck e477123
Update .github/workflows/nuget-release.yml
frederikprijck 78b7063
fix body when creating release
frederikprijck 2379016
Merge branch 'master' into feat/automated-release
frederikprijck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,30 @@ | ||
name: Return a boolean indicating if the version contains prerelease identifiers | ||
|
||
# | ||
# Returns a simple true/false boolean indicating whether the version indicates it's a prerelease or not. | ||
# | ||
# TODO: Remove once the common repo is public. | ||
# | ||
|
||
inputs: | ||
version: | ||
required: true | ||
|
||
outputs: | ||
prerelease: | ||
value: ${{ steps.get_prerelease.outputs.PRERELEASE }} | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- id: get_prerelease | ||
shell: bash | ||
run: | | ||
if [[ "${VERSION}" == *"beta"* || "${VERSION}" == *"alpha"* ]]; then | ||
echo "PRERELEASE=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "PRERELEASE=false" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
VERSION: ${{ inputs.version }} |
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,42 @@ | ||
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 | ||
|
||
outputs: | ||
release-notes: | ||
value: ${{ steps.get_release_notes.outputs.RELEASE_NOTES }} | ||
|
||
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.setOutput('RELEASE_NOTES', pulls[0].body); | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.token }} | ||
REPO_OWNER: ${{ inputs.repo_owner }} | ||
REPO_NAME: ${{ inputs.repo_name }} | ||
VERSION: ${{ inputs.version }} |
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,26 @@ | ||
name: Return the version extracted from the branch name | ||
|
||
# | ||
# Returns the version from the .version file. | ||
# | ||
# TODO: Remove once the common repo is public. | ||
# | ||
|
||
inputs: | ||
working-directory: | ||
default: './' | ||
|
||
outputs: | ||
version: | ||
value: ${{ steps.get_version.outputs.VERSION }} | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- id: get_version | ||
shell: bash | ||
working-directory: ${{ inputs.working-directory }} | ||
run: | | ||
VERSION=$(head -1 .version) | ||
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT |
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,36 @@ | ||
name: Publish release to NuGet | ||
|
||
inputs: | ||
dotnet-version: | ||
required: true | ||
nuget-token: | ||
required: true | ||
project-path: | ||
required: true | ||
nuget-directory: | ||
required: true | ||
nuspec-file: | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: ${{ inputs.dotnet-version }} | ||
|
||
- name: Setup NuGet | ||
uses: nuget/setup-nuget@v1 | ||
|
||
- name: Create NuGet packages | ||
shell: pwsh | ||
run: nuget pack ${{ inputs.nuspec-file }} -OutputDirectory ${{ inputs.nuget-directory }} | ||
|
||
- name: Publish NuGet packages | ||
shell: pwsh | ||
run: | | ||
foreach($file in (Get-ChildItem "${{ inputs.nuget-directory }}" -Recurse -Include *.nupkg)) { | ||
nuget push $file -ApiKey "${{ inputs.nuget-token }}" -Source https://api.nuget.org/v3/index.json -SkipDuplicate -NonInteractive | ||
} | ||
|
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,74 @@ | ||
name: Create NuGet and GitHub Release | ||
|
||
|
||
### TODO: Replace instances of './.github/actions/' w/ `auth0/dx-sdk-actions` and append `@latest` after the common `dx-sdk-actions` repo is made public. | ||
### DO NOT replace nuget-publish, but keep the local version as it is slightly different as opposed to the one in auth0/dx-sdk-actions to support the mono repository structure. | ||
|
||
inputs: | ||
dotnet-version: | ||
required: true | ||
nuget-token: | ||
required: true | ||
github-token: | ||
required: true | ||
project-path: | ||
required: true | ||
nuget-directory: | ||
required: true | ||
nuspec-file: | ||
required: true | ||
tag-prefix: | ||
default: '' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
# Get the version from the branch name | ||
- id: get_version | ||
uses: ./.github/actions/get-version | ||
with: | ||
working-directory: ${{ inputs.project-path }} | ||
|
||
# Get the prerelease flag from the branch name | ||
- id: get_prerelease | ||
uses: ./.github/actions/get-prerelease | ||
with: | ||
version: ${{ steps.get_version.outputs.version }} | ||
|
||
# Get the release notes | ||
- id: get_release_notes | ||
uses: ./.github/actions/get-release-notes | ||
with: | ||
token: ${{ inputs.github-token }} | ||
version: ${{ inputs.tag-prefix }}${{ 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 | ||
uses: ./.github/actions/tag-exists | ||
with: | ||
tag: ${{ inputs.tag-prefix }}${{ steps.get_version.outputs.version }} | ||
token: ${{ inputs.github-token }} | ||
|
||
# Publish the release to our package manager | ||
- uses: ./.github/actions/nuget-publish | ||
if: steps.tag_exists.outputs.exists == 'false' | ||
with: | ||
dotnet-version: ${{ inputs.dotnet-version }} | ||
project-path: ${{ inputs.project-path }} | ||
nuget-token: ${{ inputs.nuget-token }} | ||
nuget-directory: ${{ inputs.nuget-directory }} | ||
nuspec-file: ${{ inputs.nuspec-file }} | ||
|
||
# Create a release for the tag | ||
- uses: ./.github/actions/release-create | ||
if: steps.tag_exists.outputs.exists == 'false' | ||
with: | ||
token: ${{ inputs.github-token }} | ||
name: ${{ steps.get_version.outputs.version }} | ||
# body: ${{ steps.get_release_notes.outputs.release-notes }} | ||
body: '' | ||
tag: ${{ inputs.tag-prefix }}${{ steps.get_version.outputs.version }} | ||
commit: ${{ github.sha }} | ||
prerelease: ${{ steps.get_prerelease.outputs.prerelease }} |
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,47 @@ | ||
name: Create a GitHub release | ||
|
||
# | ||
# Creates a GitHub release with the given version. | ||
# | ||
# TODO: Remove once the common repo is public. | ||
# | ||
|
||
inputs: | ||
token: | ||
required: true | ||
files: | ||
required: false | ||
name: | ||
required: true | ||
body: | ||
required: true | ||
tag: | ||
required: true | ||
commit: | ||
required: true | ||
draft: | ||
default: false | ||
required: false | ||
prerelease: | ||
default: false | ||
required: false | ||
fail_on_unmatched_files: | ||
default: true | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 | ||
with: | ||
body: ${{ inputs.body }} | ||
name: ${{ inputs.name }} | ||
tag_name: ${{ inputs.tag }} | ||
target_commitish: ${{ inputs.commit }} | ||
draft: ${{ inputs.draft }} | ||
prerelease: ${{ inputs.prerelease }} | ||
fail_on_unmatched_files: ${{ inputs.fail_on_unmatched_files }} | ||
files: ${{ inputs.files }} | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.token }} |
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,36 @@ | ||
name: Return a boolean indicating if a tag already exists for the repository | ||
|
||
# | ||
# Returns a simple true/false boolean indicating whether the tag exists or not. | ||
# | ||
# TODO: Remove once the common repo is public. | ||
# | ||
|
||
inputs: | ||
token: | ||
required: true | ||
tag: | ||
required: true | ||
|
||
outputs: | ||
exists: | ||
description: 'Whether the tag exists or not' | ||
value: ${{ steps.tag-exists.outputs.EXISTS }} | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- id: tag-exists | ||
shell: bash | ||
run: | | ||
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/${TAG_NAME}" | ||
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s -H "Authorization: token ${GITHUB_TOKEN}") | ||
if [ "$http_status_code" -ne "404" ] ; then | ||
echo "EXISTS=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "EXISTS=false" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
TAG_NAME: ${{ inputs.tag }} | ||
GITHUB_TOKEN: ${{ inputs.token }} |
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,50 @@ | ||
name: Create NuGet and GitHub Release | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
dotnet-version: | ||
default: '6.0.x' | ||
type: string | ||
project-path: | ||
required: true | ||
type: string | ||
tag-prefix: | ||
default: '' | ||
type: string | ||
nuspec-file: | ||
type: string | ||
required: true | ||
secrets: | ||
github-token: | ||
required: true | ||
nuget-token: | ||
required: true | ||
|
||
jobs: | ||
release: | ||
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')) | ||
runs-on: windows-latest | ||
environment: release | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/download-artifact@v4 | ||
ewanharris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
path: './src' | ||
name: build | ||
|
||
- id: release_ios | ||
frederikprijck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: ./.github/actions/nuget-release | ||
with: | ||
dotnet-version: ${{ inputs.dotnet-version }} | ||
project-path: ${{ inputs.project-path }} | ||
tag-prefix: ${{ inputs.tag-prefix }} | ||
nuget-directory: ${{ inputs.project-path }}/nuget | ||
nuget-token: ${{ secrets.nuget-token }} | ||
github-token: ${{ secrets.github-token }} | ||
nuspec-file: ${{ inputs.nuspec-file }} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this and the get-release-notes step for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, we should keep it (well uncomment it) !