Skip to content

Create release PR for new patch version #41

Create release PR for new patch version

Create release PR for new patch version #41

Workflow file for this run

name: Create release PR
run-name: Create release PR for new ${{ github.event.inputs.version }} version
on:
workflow_dispatch:
inputs:
version:
required: true
type: choice
description: "What type of release is this"
options:
- "major"
- "minor"
- "patch"
jobs:
create-release-pr:
name: Create release PR
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
new_version: ""
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
- name: Setup Go 1.21.x
uses: actions/setup-go@v4
with:
go-version: '1.21.x'
cache-dependency-path: ${{ github.workspace }}/src/go.sum
- name: Bump version and push
run: |
git config --global user.email "[email protected]"
git config --global user.name "cjlapao"
NEW_VERSION=$(./scripts/workflows/increment-version.sh ${{ inputs.version }})
jq --arg new_version "$NEW_VERSION" '.version = $new_version' version.json > "tmp.json" && mv "tmp.json" "version.json"
sed -i "/^version:/c\version: \"$NEW_VERSION\"" ./helm/Chart.yaml
sed -i "/^appVersion:/c\appVersion: \"$NEW_VERSION\"" ./helm/Chart.yaml
sed -i "/^var ver =/c\var ver = \"$NEW_VERSION\"" ./src/main.go
sed -i "/^// @version/c\// @version $NEW_VERSION" ./src/main.go
git checkout -b release/$NEW_VERSION
go install github.com/swaggo/swag/cmd/swag@latest
cd src
go mod tidy
swag fmt
swag init -g main.go
cd ..
git add version.json ./src/* ./helm/Chart.yaml
git commit -m "Release extension version $NEW_VERSION"
git push --set-upstream origin release/$NEW_VERSION
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
- name: Create PR
run: |
LAST_PR=$(gh pr list --repo ${{ github.repository }} --limit 1 --state merged --search "Release version" --json number | jq -r '.[0].number')
./scripts/workflows/generate-release-notes.sh $LAST_PR ${{ env.new_version }}
gh pr create \
--title "Release version ${{ env.new_version }}" \
--body-file releasenotes.md \
--base main \
--head release/${{ env.new_version }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}