Skip to content

Commit

Permalink
chore(repo): pivot releases to creating a pr
Browse files Browse the repository at this point in the history
as mentioned in #15,
it turns out our branch protections will prevent us from pushing to
`main` in a github action.

in the interest of time and to provide some release consistency to the
rest of the team, this commmit pivots the existing `release-prod`
workflow to a workflow that will only create a pull request that bumps
the version of the project.

in a separate commit/pr, we shall introduce a new workflow to do the
actual publish
  • Loading branch information
rwaskiewicz committed Mar 15, 2024
1 parent 82274e1 commit 5c099bf
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions .github/workflows/release-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ jobs:
name: Build
uses: ./.github/workflows/build.yml

release_stencil_playwright:
name: Publish Prod Build
create_stencil_playwright_release_pr:
name: Generate Stencil Playwright Release PR
needs: [build_stencil_playwright]
runs-on: ubuntu-latest
needs: [ build_stencil_playwright ]
permissions:
contents: write
id-token: write
steps:
# Log the input from GitHub Actions for easy traceability
- name: Log GitHub Input
Expand All @@ -48,38 +45,40 @@ jobs:
path: .
filename: stencil-playwright-build.zip

- name: Delete the Zip File
run: rm stencil-playwright-build.zip

- name: Bump the Version
run: npm version ${{ inputs.version }} --no-git-tag

- name: Log Generated Changes
run: git --no-pager diff
shell: bash

# Commit changes resulting from bumping the version
# Note: The commit message is the result of performing the following actions:
# 1. Searching `package.json` for the string "version"
# 2. Assuming the first entry returned corresponds to this project's the version string
# 3. Stripping out all double quotes and commas from the version itself ($2 in awk corresponds to only the version here)
# 4. Printing the version string, prepended with a 'v' for 'version'
- name: Commit Release Preparations
- name: Generate Version String and Branch Name
id: name_gen
run: |
git config user.name "Stencil Release Bot (on behalf of ${{ github.actor }})"
git config user.email "stencil-release-bot@ionic.io"
git add .
git commit -m "$(cat package.json | grep version | head -n 1 | awk '{ gsub(/"|,/, "", $2); print "v"$2}')"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_STR=$(jq '.version' package.json | sed s/\"//g)
echo "VERSION_STR=$VERSION_STR" >> "$GITHUB_OUTPUT"
echo "BRANCH_NAME=release/$VERSION_STR-run-${{ github.run_number }}-${{ github.run_attempt }}" >> "$GITHUB_OUTPUT"
shell: bash

- name: Push Branch to GitHub
- name: Print Version String and Branch Name
run: |
git push origin
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
echo Version: ${{ steps.name_gen.outputs.VERSION_STR }}
echo Branch Name: ${{ steps.name_gen.outputs.BRANCH_NAME }}
shell: bash

- name: Upload Build Artifacts
uses: ./.github/workflows/actions/upload-archive
- name: Create the Pull Request
uses: peter-evans/create-pull-request@a4f52f8033a6168103c2538976c07b467e8163bc # v6.0.1
with:
name: stencil-playwright-for-publish
output: stencil-playwright-build-for-publish.zip
paths: ./dist/
# specifies the name of the branch to create off of the base branch
branch: '${{ steps.name_gen.outputs.BRANCH_NAME }}'
# TODO(STENCIL-???): Remove this once pipeline is 'ready'
draft: true
# create a commit message containing the semver version, prefixed with a 'v' - e.g. 'v4.1.0'
commit-message: 'v${{ steps.name_gen.outputs.VERSION_STR }}'
# set the title of the pull request, otherwise it'll default to generic message
title: 'Release v${{ steps.name_gen.outputs.VERSION_STR }}'
# the body of the pull request summary can be empty
body: ''

0 comments on commit 5c099bf

Please sign in to comment.