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

Create Release workflow #3

Merged
merged 3 commits into from
Apr 28, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Create release pull request github action workflow
  • Loading branch information
ogaclejapan committed Apr 28, 2024
commit 8c566de637059c558ea9169a5103dab184453306
65 changes: 65 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Create Release PR
on:
workflow_dispatch:
inputs:
version:
description: Version to release
type: string
required: true

jobs:
create-release-pr:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
RELEASE_PR_BRANCH: release/${{ github.event.inputs.version }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Git Config #https://github.com/orgs/community/discussions/26560
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Git Checkout
run: |
git checkout -b $RELEASE_PR_BRANCH origin/$GITHUB_REF_NAME

- name: Update Version
run: |
echo "Bump up version to $RELEASE_VERSION"
sed -i "/version=/c version=$RELEASE_VERSION" gradle.properties
if [[ -n $(git status -s) ]]; then
git add gradle.properties
git commit -m "Bump up version to $RELEASE_VERSION"
else
exit 1
fi

- name: Git Push
run: |
git push origin $RELEASE_PR_BRANCH

- name: Create PR
run: |
RELEASE_PREVIOUS_TAG=$(git describe --tags --abbrev=0 origin/$GITHUB_REF_NAME)
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/$GITHUB_REPOSITORY/releases/generate-notes \
-f configuration_file_path=".github/release.yml" \
-f tag_name="$RELEASE_VERSION" \
-f target_commitish="$RELEASE_PR_BRANCH" \
-f previous_tag_name="$RELEASE_PREVIOUS_TAG" | jq -r .body > release.txt

gh pr create --title "Release v$RELEASE_VERSION" --body-file release.txt --base $GITHUB_REF_NAME --assignee $GITHUB_TRIGGERING_ACTOR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}