Skip to content

Commit

Permalink
ci: Set up release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
janbuchar committed Apr 28, 2024
1 parent 2995cd2 commit 0325a3c
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Publish a release

on:
workflow_dispatch:
inputs:
release_type:
required: true
type: choice
options:
- patch
- minor
- major

env:
PR_BRANCH: release-ci-${{ github.sha }}

jobs:

prepare_metadata:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump_version.outputs.version }}
release_sha: ${{ steps.merge_pr.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Jan Buchar"
- name: Bump version in package.json
id: bump_version
run: |
npm version ${{ github.event.inputs.release_type }}
echo version=$( node -p "require('./package.json').version" ) >> "$GITHUB_OUTPUT"
- name: Create PR
run: |
git switch -c ${{ env.PR_BRANCH }}
gh pr create \
--base master \
--head ${{ env.PR_BRANCH }} \
--title "chore: Release ${{ steps.bump_version.outputs.version }} [skip-ci]" \
--body "Automated pull request - update to ${{ steps.bump_version.outputs.version }}"
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
- name: Approve and merge PR
id: merge_pr
run: |
gh pr review --approve ${{ env.PR_BRANCH }}
gh pr merge --squash --auto --delete-branch ${{ env.PR_BRANCH }}
echo sha=$( gh pr view --json mergeCommit ${{ env.PR_BRANCH }} | jq --raw-output .mergeCommit.oid ) >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

gh_release:
runs-on: ubuntu-latest
needs: prepare_metadata
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: release-${{ needs.prepare_metadata.outputs.version }}
name: Release ${{ needs.prepare_metadata.outputs.version }}
target_commitish: ${{ needs.prepare_metadata.outputs.release_sha }}

0 comments on commit 0325a3c

Please sign in to comment.