[GitHub] Create release action workflows (#5743)

* Create release actions

* Add release branch to push/pull events that invoke test workflows
This commit is contained in:
Sirz Benjie 2025-05-03 03:47:04 -05:00 committed by GitHub
parent cedeaf8668
commit 9283be652d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 97 additions and 5 deletions

73
.github/workflows/create-release.yml vendored Normal file
View File

@ -0,0 +1,73 @@
name: Create Release Branch
on:
workflow_dispatch:
inputs:
versionName:
description: "Name of version (i.e. 1.9.0)"
type: string
required: true
confirmVersion:
type: string
required: true
description: "Confirm version name"
# explicitly specify the necessary scopes
permissions:
pull-requests: write
actions: write
contents: write
jobs:
create-release:
if: github.repository == 'pagefaultgames/pokerogue' && (vars.BETA_DEPLOY_BRANCH == '' || ! startsWith(vars.BETA_DEPLOY_BRANCH, 'release'))
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed for github cli commands
runs-on: ubuntu-latest
steps:
- name: Validate provided version
# Ensure version matches confirmation and conforms to expected pattern.
run: |
if [[ "${{ github.event.inputs.versionName }}" != "${{ github.event.inputs.confirmVersion }}" ]]; then
echo "Version name does not match confirmation. Exiting."
exit 1
fi
if [[ ! "${{ github.event.inputs.versionName }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version name must follow the format X.Y.Z where X, Y, and Z are all numbers. Exiting..."
exit 1
fi
shell: bash
- name: Check out code
uses: actions/checkout@v4
with:
submodules: "recursive"
# Always base off of beta branch, regardless of the branch the workflow was triggered from.
ref: beta
- name: Create release branch
run: git checkout -b release
# In order to be able to open a PR into beta, we need the branch to have at least one change.
- name: Overwrite RELEASE file
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
echo "Release v${{ github.event.inputs.versionName }}" > RELEASE
git add RELEASE
git commit -m "Stage release v${{ github.event.inputs.versionName }}"
- name: Push new branch
run: git push origin release
# The repository variable is used by the deploy-beta workflow to determine whether to deploy from beta or release.
- name: Set repository variable
run: GITHUB_TOKEN="${{ secrets.RW_VARS_PAT }}" gh variable set BETA_DEPLOY_BRANCH --body "release"
- name: Create pull request to main
run: |
gh pr create --base main \
--head release \
--title "Release v${{ github.event.inputs.versionName }} to main" \
--body "This PR is for the release of v${{ github.event.inputs.versionName }}, and was created automatically by the GitHub Actions workflow invoked by ${{ github.actor }}" \
--draft
- name: Create pull request to beta
run: |
gh pr create --base beta \
--head release \
--title "Release v${{ github.event.inputs.versionName }} to beta" \
--body "This PR is for the release of v${{ github.event.inputs.versionName }}, and was created automatically by the GitHub Actions workflow invoked by ${{ github.actor }}" \
--draft

View File

@ -4,18 +4,23 @@ on:
push: push:
branches: branches:
- beta - beta
- release
workflow_run:
types: completed
workflows: ["Post Release Deleted"]
jobs: jobs:
deploy: deploy:
if: github.repository == 'pagefaultgames/pokerogue' if: github.repository == 'pagefaultgames/pokerogue' && github.ref_name == ${{ vars.BETA_DEPLOY_BRANCH || 'beta' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
submodules: 'recursive' submodules: "recursive"
ref: ${{ vars.BETA_DEPLOY_BRANCH || 'beta'}}
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version-file: '.nvmrc' node-version-file: ".nvmrc"
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Build - name: Build
@ -30,5 +35,5 @@ jobs:
chmod 600 ~/.ssh/* chmod 600 ~/.ssh/*
ssh-keyscan -H ${{ secrets.BETA_SSH_HOST }} >> ~/.ssh/known_hosts ssh-keyscan -H ${{ secrets.BETA_SSH_HOST }} >> ~/.ssh/known_hosts
- name: Deploy build on server - name: Deploy build on server
run: | run: |
rsync --del --no-times --checksum -vrm dist/* ${{ secrets.BETA_SSH_USER }}@${{ secrets.BETA_SSH_HOST }}:${{ secrets.BETA_DESTINATION_DIR }} rsync --del --no-times --checksum -vrm dist/* ${{ secrets.BETA_SSH_USER }}@${{ secrets.BETA_SSH_HOST }}:${{ secrets.BETA_DESTINATION_DIR }}

View File

@ -0,0 +1,12 @@
name: Post Release Deleted
on:
delete:
jobs:
# Set the BETA_DEPLOY_BRANCH variable to beta when a release branch is deleted
update-release-var:
if: github.repository == 'pagefaultgames/pokerogue' && github.event.ref_type == 'branch' && github.event.ref == 'release'
runs-on: ubuntu-latest
steps:
- name: Set BETA_DEPLOY_BRANCH to beta
run: GITHUB_TOKEN="${{ secrets.RW_VARS_PAT }}" gh variable set BETA_DEPLOY_BRANCH --body "beta" --repo "pagefaultgames/pokerogue"

View File

@ -7,6 +7,7 @@ on:
branches: branches:
- main # Trigger on push events to the main branch - main # Trigger on push events to the main branch
- beta # Trigger on push events to the beta branch - beta # Trigger on push events to the beta branch
- release # Trigger on push events to the release branch
# go upvote https://github.com/actions/runner/issues/1182 and yell at microsoft until they fix this or ditch yml for workflows # go upvote https://github.com/actions/runner/issues/1182 and yell at microsoft until they fix this or ditch yml for workflows
paths: paths:
# src and test files # src and test files
@ -32,6 +33,7 @@ on:
branches: branches:
- main # Trigger on pull request events targeting the main branch - main # Trigger on pull request events targeting the main branch
- beta # Trigger on pull request events targeting the beta branch - beta # Trigger on pull request events targeting the beta branch
- release # Trigger on pull request events targeting the release branch
paths: # go upvote https://github.com/actions/runner/issues/1182 and yell at microsoft because until then we have to duplicate this paths: # go upvote https://github.com/actions/runner/issues/1182 and yell at microsoft because until then we have to duplicate this
# src and test files # src and test files
- "src/**" - "src/**"