Skip to content

feat(actions): add create-release-draft action #787

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

Merged
merged 1 commit into from
Jul 18, 2024
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
40 changes: 40 additions & 0 deletions .github/workflows/create-release-draft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create release draft
on:
workflow_dispatch:
pull_request:
branches:
- 'release-*'

jobs:
create-draft:
name: Create release draft
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get version
id: version
run: |
echo version=$(cat VERSION) >> $GITHUB_OUTPUT

- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Build binaries
id: binaries
run: |
make release-binaries

- name: Create release draft
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.version.outputs.version }}" \
--title "v${{ steps.version.outputs.version }}" \
--generate-notes \
--draft \
dist/release/*
31 changes: 31 additions & 0 deletions hack/create-release-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

RELEASE_BRANCH="$(git rev-parse --abbrev-ref HEAD || true)"
set -eux
set -o pipefail

### look for latest on-branch tag
PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match "*${RELEASE_BRANCH##release-}*" 2>/dev/null || true)

if [ -n "$PREVIOUS_TAG" ]; then
NEW_VERSION=$(semver-cli inc patch $PREVIOUS_TAG)
else
NEW_VERSION="${RELEASE_BRANCH##release-}.0"
fi

echo $NEW_VERSION > VERSION

IMAGE_TAG="v${NEW_VERSION}"
make manifests

git checkout -b "feat/new-version-${NEW_VERSION}"
git commit -m "Release ${NEW_VERSION}" VERSION manifests/
git push
gh label --repo $(git remote get-url origin) create --force release
gh pr --repo $(git remote get-url origin) \
create \
--base ${RELEASE_BRANCH} \
--title "Release ${NEW_VERSION}" \
--body "Release ${NEW_VERSION}" \
--label release
git checkout -