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

GHA to create releases #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
84 changes: 84 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "Create a release"

on:
workflow_call:
inputs:
ref:
description: "Ref to be tagged"
required: true
type: string
default: master
tag:
description: "Tag for new version (v1.23.4)"
required: true
type: string
base_tag:
description: "Base tag to generate commit list for release notes"
required: false
type: string
secrets:
TEMPORAL_CICD_APP_ID:
required: true
TEMPORAL_CICD_PRIVATE_KEY:
required: true

jobs:
create-release:
name: "Create a release"
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:
repository: temporalio/api-go
ref: ${{ github.event.inputs.ref }}
token: ${{ steps.generate_token.outputs.token }}
persist-credentials: true
fetch-depth: 0
fetch-tags: true
submodules: true

- name: Validate input
Copy link
Member

Choose a reason for hiding this comment

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

We should also validate that the version given here matches the api submodule version. I think we should verify that there is a release or maybe a draft referencing the api submodule commit with the same version given as input to this workflow.

env:
REF: ${{ github.event.inputs.ref }}
TAG: ${{ github.event.inputs.tag }}
BASE_TAG: ${{ github.event.inputs.base_tag }}
run: |
if ! [[ "${TAG}" =~ ^v.* ]]; then
echo "::error::Tag is not prefixed with 'v'"
exit 1
fi

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 $REF"
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: Set up Github credentials
run: |
git config --local user.name 'Temporal Data'
git config --local user.email '[email protected]'

- name: Create release
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
REF: ${{ github.event.inputs.ref }}
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"
Loading