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

Build: Add Workflow for patch releases #46

Merged
merged 5 commits into from
Jun 6, 2023
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
146 changes: 0 additions & 146 deletions .github/workflows/prepare-patch-release.WIP

This file was deleted.

154 changes: 154 additions & 0 deletions .github/workflows/prepare-patch-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Prepare patch PR
run-name: Prepare patch PR, triggered by ${{ github.triggering_actor }}

on:
push:
branches:
- next-v2
workflow_dispatch:

env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
prepare-patch-pull-request:
name: Prepare patch pull request
runs-on: ubuntu-latest
defaults:
run:
working-directory: scripts
steps:
- name: Checkout main-v2
uses: actions/checkout@v3
with:
ref: main-v2
# this needs to be set to a high enough number that it will contain the last version tag
# as of May 2023, the whole repo had 55K commits
fetch-depth: 10000

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.yarn/berry/cache
key: yarn-v1-${{ hashFiles('scripts/yarn.lock') }}

- name: Install Script Dependencies
run: |
yarn install

- name: Check if pull request is frozen
if: github.event_name != 'workflow_dispatch'
id: check-frozen
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn release:is-pr-frozen

- name: Cancel when frozen
if: steps.check-frozen.outputs.frozen == 'true' && github.event_name != 'workflow_dispatch'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# From https://stackoverflow.com/a/75809743
run: |
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}

- name: Check for unreleased changes
id: unreleased-changes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn release:unreleased-changes-exists

- name: Pick patches
id: pick-patches
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn release:pick-patches --verbose

- name: Bump version
id: version
if: steps.unreleased-changes.outputs.has-changes-to-release == 'true'
run: |
yarn release:version --release-type patch --verbose

# We need the current version to set the branch name, even when not bumping the version
- name: Get current version
id: current-version
if: steps.unreleased-changes.outputs.has-changes-to-release == 'false'
run: |
yarn release:get-current-version --verbose

- name: Write changelog
if: steps.unreleased-changes.outputs.has-changes-to-release == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn release:write-changelog ${{ steps.version.outputs.next-version }} --verbose

- name: 'Commit changes to branch: version-from-${{ steps.version.outputs.current-version }}'
working-directory: .
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b version-from-${{ steps.version.outputs.current-version }}
git add .
git commit -m "Bump version from ${{ steps.version.outputs.current-version }} to ${{ steps.version.outputs.next-version }}" || true
git push --force origin version-from-${{ steps.version.outputs.current-version }}

- name: Generate PR description
id: description
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn release:generate-pr-description --manual-cherry-picks="${{ steps.pick-patches.outputs.failed-cherry-picks }}" ${{ steps.unreleased-changes.outputs.has-changes-to-release == 'true' && format('{0} {1} {3} {4}', '--current-version', steps.version.outputs.current-version, '--next-version', steps.version.outputs.next-version) || '' }} --verbose

- name: Create or update pull request with release
if: steps.unreleased-changes.outputs.has-changes-to-release == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit \
--repo "${{github.repository }}"\
--title "Bump version from ${{ steps.version.outputs.current-version }} to ${{ steps.version.outputs.next-version }}" \
--body "${{ steps.description.outputs.description }}" \
|| \
gh pr create \
--repo "${{github.repository }}"\
--title "Bump version from ${{ steps.version.outputs.current-version }} to ${{ steps.version.outputs.next-version }}" \
--body "${{ steps.description.outputs.description }}" \
--base release/main \
--head version-from-${{ steps.version.outputs.current-version }}

- name: Create or update pull request without release
if: steps.unreleased-changes.outputs.has-changes-to-release == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit \
--repo "${{github.repository }}"\
--title "Merge patches to \`main\`" \
--body "${{ steps.description.outputs.description }}" \
|| \
gh pr create \
--repo "${{github.repository }}"\
--title "Merge patches to \`main\`" \
--body "${{ steps.description.outputs.description }}" \
--base release/main \
--head version-from-${{ steps.current-version.outputs.current-version }}

# - name: Report job failure to Discord
# if: failure()
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
# uses: Ilshidur/action-discord@master
# with:
# args: 'The GitHub Action for preparing the release pull request bumping from v${{ steps.version.outputs.current-version }} to v${{ steps.version.outputs.next-version }} (triggered by ${{ github.triggering_actor }}) failed! See run at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ jobs:
--notes "${{ steps.changelog.outputs.changelog }}" \
${{ steps.is-prerelease.outputs.prerelease && '--prerelease' || '' }}

#TODO: label picked PRs if patch release

- name: Merge ${{ github.ref_name }} into ${{ steps.target.outputs.target }}
run: |
git config --global user.name "github-actions[bot]"
Expand Down
Loading