diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 00000000..546946ab --- /dev/null +++ b/.github/workflows/create-release.yml @@ -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 diff --git a/.github/workflows/trigger-api-go-delete-release.yml b/.github/workflows/trigger-api-go-delete-release.yml new file mode 100644 index 00000000..e5b30efa --- /dev/null +++ b/.github/workflows/trigger-api-go-delete-release.yml @@ -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 diff --git a/.github/workflows/trigger-api-go-publish-release.yml b/.github/workflows/trigger-api-go-publish-release.yml new file mode 100644 index 00000000..e8c7c6f7 --- /dev/null +++ b/.github/workflows/trigger-api-go-publish-release.yml @@ -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