-
Notifications
You must be signed in to change notification settings - Fork 66
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
GHA to create release #437
Open
rodrigozhou
wants to merge
4
commits into
master
Choose a base branch
from
rodrigozhou/gha-create-tag
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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,135 @@ | ||
name: "Create release" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: "Branch to be tagged" | ||
required: true | ||
default: master | ||
tag: | ||
description: "Tag for new version (v1.23.4)" | ||
required: true | ||
base_tag: | ||
description: "Base tag to generate commit list for release notes" | ||
required: false | ||
skip_sdk_check: | ||
description: "Skip sdk-go compatibility check" | ||
type: boolean | ||
|
||
jobs: | ||
prepare-inputs: | ||
name: "Prepare inputs" | ||
runs-on: ubuntu-latest | ||
outputs: | ||
api_commit_sha: ${{ steps.pin_commits.outputs.api_commit_sha }} | ||
api_go_commit_sha: ${{ steps.pin_commits.outputs.api_go_commit_sha }} | ||
steps: | ||
- name: Checkout api | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.branch }} | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
path: api | ||
|
||
- name: Checkout api-go | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: temporalio/api-go | ||
ref: ${{ github.event.inputs.branch }} | ||
submodules: true | ||
path: api-go | ||
|
||
- name: Validate inputs | ||
env: | ||
BRANCH: ${{ github.event.inputs.branch }} | ||
TAG: ${{ github.event.inputs.tag }} | ||
BASE_TAG: ${{ github.event.inputs.base_tag }} | ||
working-directory: ./api | ||
run: | | ||
if ! [[ "${TAG}" =~ ^v.* ]]; then | ||
echo "::error::Tag is not prefixed with 'v'" | ||
exit 1 | ||
fi | ||
|
||
if [[ -n "$(git tag -l "$TAG")" ]]; then | ||
echo "::error::Tag already exists" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$BASE_TAG" || -z "$(git tag -l "$BASE_TAG")" ]]; then | ||
echo "::error::Base tag not specified or does not exist" | ||
exit 1 | ||
fi | ||
|
||
- name: Pin commits sha | ||
id: pin_commits | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BRANCH: ${{ github.event.inputs.branch }} | ||
run: | | ||
API_COMMIT_SHA=$(git -C ./api rev-parse HEAD) | ||
API_GO_COMMIT_SHA=$(git -C ./api-go rev-parse HEAD) | ||
API_GO_API_COMMIT_SHA=$(git -C ./api-go rev-parse HEAD:proto/api) | ||
if [[ "${API_GO_API_COMMIT_SHA}" != "${API_COMMIT_SHA}" ]]; then | ||
echo "::error::api-go ref ${API_GO_COMMIT_SHA} does not reference api ref ${API_COMMIT_SHA}, api-go repo might not be up-to-date." | ||
exit 1 | ||
fi | ||
echo "api_commit_sha=$API_COMMIT_SHA" >> "$GITHUB_OUTPUT" | ||
echo "api_go_commit_sha=$API_GO_COMMIT_SHA" >> "$GITHUB_OUTPUT" | ||
|
||
check-compatibility-sdk-go: | ||
needs: prepare-inputs | ||
if: ${{ github.event.inputs.skip_sdk_check == false || github.event.inputs.skip_sdk_check == 'false' }} | ||
uses: temporalio/api-go/.github/workflows/check-sdk-compat.yml@master | ||
with: | ||
sdk_ref: latest | ||
api_ref: ${{ needs.prepare-inputs.outputs.api_go_commit_sha }} | ||
|
||
create-release: | ||
name: "Create release" | ||
needs: [prepare-inputs, check-compatibility-sdk-go] | ||
if: | | ||
!cancelled() && | ||
needs.prepare-inputs.result == 'success' && | ||
contains(fromJSON('["success", "skipped"]'), needs.check-compatibility-sdk-go.result) | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Generate token | ||
id: generate_token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }} | ||
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }} | ||
owner: ${{ github.repository_owner }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ needs.prepare-inputs.outputs.api_commit_sha }} | ||
token: ${{ steps.generate_token.outputs.token }} | ||
|
||
- name: Create release | ||
env: | ||
GH_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
REF: ${{ needs.prepare-inputs.outputs.api_commit_sha }} | ||
TAG: ${{ github.event.inputs.tag }} | ||
BASE_TAG: ${{ github.event.inputs.base_tag }} | ||
run: | | ||
gh repo set-default ${{ github.repository }} | ||
gh release create "$TAG" --target "$REF" --latest --generate-notes --notes-start-tag "$BASE_TAG" --draft | ||
|
||
release-api-go: | ||
needs: [prepare-inputs, create-release] | ||
if: | | ||
!cancelled() && | ||
needs.create-release.result == 'success' | ||
uses: temporalio/api-go/.github/workflows/create-release.yml@master | ||
with: | ||
ref: ${{ needs.prepare-inputs.outputs.api_go_commit_sha }} | ||
tag: ${{ github.event.inputs.tag }} | ||
api_commit_sha: ${{ needs.prepare-inputs.outputs.api_commit_sha }} | ||
base_tag: ${{ github.event.inputs.base_tag }} | ||
secrets: inherit |
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,13 @@ | ||
name: "Trigger api-go delete release" | ||
|
||
on: | ||
release: | ||
types: [deleted] | ||
|
||
jobs: | ||
trigger-api-go-delete-release: | ||
uses: temporalio/api-go/.github/workflows/delete-release.yml@master | ||
with: | ||
tag: ${{ github.event.release.tag_name }} | ||
api_commit_sha: ${{ github.event.release.target_commitish }} | ||
secrets: inherit |
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,13 @@ | ||
name: "Trigger api-go publish release" | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
trigger-api-go-publish-release: | ||
uses: temporalio/api-go/.github/workflows/publish-release.yml@master | ||
with: | ||
tag: ${{ github.event.release.tag_name }} | ||
api_commit_sha: ${{ github.event.release.target_commitish }} | ||
secrets: inherit |
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.
I would have imagined this would be the default, is it not so?
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.
Github actions doesn't work well when the dependency has a condition for running.
In this case, the
check-compatibility-sdk-go
job runs only if the flag is set. So, even if I add it toneeds
, thecreate-release
job never runs. So, I need to manually check the conditions.