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

Update release workflow #175

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
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
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}"
Copy link
Contributor Author

@oliversun9 oliversun9 Nov 9, 2023

Choose a reason for hiding this comment

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

We could also add --notes 'replace me' as a placeholder for us to replace, but most of the time it will just get deleted because nothing is changed about this action, except for using a newer version of the CLI

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.