Skip to content

create-release

create-release #75

name: create-release
on:
workflow_dispatch:
inputs:
type:
type: choice
description: 'Type of release'
options: # put in ascending order to not accidentally cut a "major" release PR
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
required: true
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: true
- uses: pnpm/action-setup@v2
- name: set git config for pnpm version, git push
run: |
git config --global user.name "GitHub Actions"
git config --global user.email [email protected]
- name: set-version
id: version
run: |
if [[ ${{ github.event.inputs.type }} != pre* ]]
then
version=$(pnpm version ${{ github.event.inputs.type }} --no-git-tag-version)
else
version=$(pnpm version ${{ github.event.inputs.type }} --preid next --no-git-tag-version)
fi
echo "version=$version" >> $GITHUB_OUTPUT
- run: echo "::debug::version is ${{ steps.version.outputs.version }}"
- run: echo "::notice title="releasing"::${{ steps.version.outputs.version }}"
- if: ${{ steps.version.outputs.version == '' }}
run: echo "::error ::Invalid version" && exit 1
# - uses: actions/setup-node@v3 # is this needed???
# with:
# node-version-file: '.node-version'
# cache: 'pnpm'
- id: branch
run: echo "name=release/${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
- name: Create release branch
run: git checkout -b ${{ steps.branch.outputs.name }}
# this is not required when pnpm is creating the git tag
- name: add and commit changes
run: |
git add package.json
git commit -m '[automated] release: ${{ steps.version.outputs.version }}'
- run: git push origin ${{ steps.branch.outputs.name }}
- id: pr
run: |
url=$(gh pr create --title "release: ${{ steps.version.outputs.version }}" --body "Automated PR created to release a new version of the project")
echo "link=$url" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo '${{ steps.pr.outputs.link }}'
- run: echo ::notice title="created"::${{ steps.pr.outputs.link }}
- run: echo ::notice title="type"::${{ github.event.inputs.type }}