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