-
Notifications
You must be signed in to change notification settings - Fork 20
66 lines (65 loc) · 2.5 KB
/
create-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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 }}