Skip to content

Commit

Permalink
Update release workflow (#175)
Browse files Browse the repository at this point in the history
Split `release.yaml` into `create-release-pr.yaml` and
`draft-release.yaml`.

Remove `test.yaml`, seems like it shouldn't be on main in the first
place?
  • Loading branch information
oliversun9 authored Nov 10, 2023
1 parent 1158f4f commit 81bf726
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 124 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Create Release PR
on:
workflow_dispatch:
inputs:
version:
type: string
description: The version you intend to release (eg x.y.z)
required: true
permissions:
contents: write
pull-requests: write
env:
VERSION: ${{ github.event.inputs.version }}
APP_ID: 257262
jobs:
update_version:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.version != '' }}
steps:
- name: Validate input version
if: ${{ startsWith(github.event.inputs.version, 'v') }}
run: |
echo "error: version must not start with 'v'."
exit 1
- name: Get GitHub app token
uses: actions/create-github-app-token@v1
id: app_token
with:
app-id: ${{ env.APP_ID }}
private-key: ${{ secrets.TOKEN_EXCHANGE_GH_APP_PRIVATE_KEY }}
- name: Checkout repository code
uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19.x'
- name: Update docs Version
run: make updateversion VERSION=${{env.VERSION}}
- name: Create PR
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
BRANCH="release/v${VERSION}"
git switch -C ${BRANCH}
git add .
git commit -m "Update version to ${VERSION}"
git push --set-upstream origin --force ${BRANCH}
gh pr create --title "Release v${VERSION}" --body "Release prepared for ${VERSION}"
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
41 changes: 41 additions & 0 deletions .github/workflows/draft-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Draft Release
on:
pull_request:
types: [closed]
workflow_dispatch:
inputs:
version:
type: string
description: The released CLI version without 'v'. For example, 1.0.0.
permissions:
contents: write
jobs:
draft_release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release')) }}
steps:
- name: Validate input version
if: ${{ startsWith(github.event.inputs.version, 'v') }}
run: |
echo "error: version must not start with 'v'."
exit 1
- name: Set VERSION variable
# The head ref looks like release/v1.0.0, and we need to trim the string up to the `/v`.
run: |
VERSION="${{ github.event.inputs.version || github.head_ref}}"
echo "VERSION=${VERSION##*/v}" >> $GITHUB_ENV
- name: Checkout repository code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Sync v1 branch
run: |
git fetch origin
git switch v1
git merge origin/main
git push origin v1
- name: Release
run: gh release create --draft --title "v${VERSION}" "v${VERSION}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112 changes: 0 additions & 112 deletions .github/workflows/release.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/test.yaml

This file was deleted.

0 comments on commit 81bf726

Please sign in to comment.