-
Notifications
You must be signed in to change notification settings - Fork 32
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 tags/releases #170
Open
rodrigozhou
wants to merge
1
commit 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 a tag" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: "Branch to be tagged" | ||
required: true | ||
default: main | ||
tag: | ||
description: "Tag for new version (v1.23.4)" | ||
required: true | ||
create_release: | ||
description: "Create release" | ||
type: boolean | ||
default: true | ||
base_tag: | ||
description: "Base tag to generate commit list for release notes" | ||
required: false | ||
|
||
jobs: | ||
create-tag: | ||
name: "Create a tag" | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
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 }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.branch }} | ||
token: ${{ steps.generate_token.outputs.token }} | ||
persist-credentials: true | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
submodules: true | ||
|
||
- name: Set up Github credentials | ||
run: | | ||
git config --local user.name 'Temporal Data' | ||
git config --local user.email '[email protected]' | ||
|
||
- name: Prepare new version string | ||
id: new_version | ||
env: | ||
TAG: ${{ github.event.inputs.tag }} | ||
run: | | ||
if [[ "${TAG}" =~ ^v.* ]]; then | ||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "tag=v${TAG}" >> "$GITHUB_OUTPUT" | ||
fi | ||
|
||
- name: Validate input | ||
env: | ||
BRANCH: ${{ github.event.inputs.branch }} | ||
TAG: ${{ steps.new_version.outputs.tag }} | ||
CREATE_RELEASE: ${{ github.event.inputs.create_release }} | ||
BASE_TAG: ${{ github.event.inputs.base_tag }} | ||
run: | | ||
if [[ -n "$(git tag -l "$TAG")" && "$(git rev-parse "$TAG")" != "$(git rev-parse HEAD)" ]]; then | ||
echo "::error::Tag already exists and it doesn't reference current HEAD of branch $BRANCH" | ||
exit 1 | ||
fi | ||
|
||
if [[ "$CREATE_RELEASE" == "true" ]]; then | ||
if [[ -z "$BASE_TAG" || -z "$(git tag -l "$BASE_TAG")" ]]; then | ||
echo "::error::Base tag not specified or does not exist" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
- name: Create and push tag | ||
env: | ||
BRANCH: ${{ github.event.inputs.branch }} | ||
TAG: ${{ steps.new_version.outputs.tag }} | ||
run: | | ||
if [ -z "$(git tag -l "$TAG")" ]; then | ||
git tag "$TAG" | ||
git push origin "$TAG" | ||
fi | ||
|
||
- name: Create release | ||
if: ${{ github.event.inputs.create_release == 'true' }} | ||
env: | ||
GH_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
TAG: ${{ steps.new_version.outputs.tag }} | ||
BASE_TAG: ${{ github.event.inputs.base_tag }} | ||
run: | | ||
TEMPFILE=$(mktemp) | ||
cat > "$TEMPFILE" <<- EOF | ||
**Full Changelog**: https://github.com/temporalio/api-go/compare/${BASE_TAG}...${TAG} | ||
EOF | ||
|
||
gh repo set-default ${{ github.repository }} | ||
gh release create "$TAG" --verify-tag --title "$TAG" -F "$TEMPFILE" | ||
|
||
update-consumer-deps: | ||
name: Update consumers dependency on api-go | ||
if: ${{ github.event.inputs.create_release == 'true' }} | ||
needs: create-tag | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
repo: | ||
- sdk | ||
- temporal | ||
- bench-go | ||
- canary-go | ||
- samples-go | ||
- ui | ||
|
||
steps: | ||
- name: Update api-go in ${{ matrix.repo }} | ||
id: update-repo-deps | ||
uses: ./.github/workflows/update-repo-deps.yml | ||
with: | ||
repo: "temporalio/${{ matrix.repo }}" | ||
tag: ${{ steps.new_version.outputs.tag }} | ||
secrets: | ||
token: ${{ steps.generate_token.outputs.token }} | ||
|
||
- run: | | ||
echo "PR ${{ matrix.repo }}: ${{ steps.update-repo-deps.outputs.pr_link }}" >> $GITHUB_STEP_SUMMARY |
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,53 @@ | ||
name: "Update repository dependency on api-go" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
repo: | ||
description: "Repository to be udpated" | ||
required: true | ||
tag: | ||
description: "Tag to be used" | ||
required: true | ||
secrets: | ||
token: | ||
required: true | ||
|
||
jobs: | ||
update-repo-deps: | ||
name: Update repo deps | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.inputs.repo }} | ||
token: ${{ secrets.token }} | ||
persist-credentials: true | ||
|
||
- name: Update go.mod | ||
env: | ||
TAG: ${{ github.events.input.tag }} | ||
run: | | ||
for gomod in $(find . -name "go.mod"); do | ||
cd $(dirname $gomod) | ||
if [[ $(cat go.mod | grep -c "go\.temporal\.io/api v.*$") -gt 0 ]]; then | ||
go get go.temporal.io/api@${TAG} | ||
go mod tidy | ||
fi | ||
cd - | ||
done | ||
|
||
BRANCH="temporal-data/update-api-go-${TAG}-$(git rev-parse --short HEAD)" | ||
git checkout -b $BRANCH | ||
git add . | ||
git commit -m "Bump api-go to $TAG" | ||
git push origin $BRANCH | ||
pr_link=$(gh pr create --fill --reviewer ${{ github.actor }},${{ github.triggering_actor }}) | ||
echo "PR link for ${{ github.events.input.repo }}: $pr_link" | ||
echo "pr_link=$pr_link" >> $GITHUB_OUTPUT |
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.
Blindly bumping api-go is not recommended. Firstly, rarely do users use this without SDK, and the SDK needs to be vetted on the API bump. Secondly, it makes assumptions about where people's go.mod's live which is not necessarily accurate either. If a certain repo wants some automation to bump a certain dependency it has, that automation should be in that repo IMO, not this shared one.