-
Notifications
You must be signed in to change notification settings - Fork 9
198 lines (172 loc) · 6.89 KB
/
release.yaml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
dryRun:
description: 'Dry Run'
required: true
type: boolean
default: true
releaseVersion:
description: 'Custom Version (major.minor.patch; leave empty for automatic determination)'
required: true
type: choice
default: 'auto'
options:
- 'auto'
- 'major'
- 'minor'
- 'patch'
jobs:
analyse-changed-packages:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.changed-packages.outputs.CHANGED }}
changedPackages: ${{ steps.changed-packages.outputs.CHANGED_PACKAGES }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- run: |
SINCE=$(git rev-list --tags --max-count=1)
echo SINCE=$SINCE >> $GITHUB_OUTPUT
echo SINCE=$SINCE
id: since
- run: |
pnpm list -r --json --filter "...[$SINCE]" | jq '[.[] | select(.private == false) | {name, path}]' > ./tmp.json
CHANGED_PACKAGES=$(jq '[.[] | .name]' ./tmp.json)
echo CHANGED_PACKAGES=$CHANGED_PACKAGES >> $GITHUB_OUTPUT
echo CHANGED_PACKAGES=$CHANGED_PACKAGES
id: changed-packages
env:
SINCE: ${{ steps.since.outputs.SINCE }}
release:
needs: [analyse-changed-packages]
runs-on: ubuntu-latest
if: ${{ needs.analyse-changed-packages.outputs.changedPackages != '[]'}}
strategy:
fail-fast: false
max-parallel: 1
matrix:
package: ${{fromJson(needs.analyse-changed-packages.outputs.changedPackages)}}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
# token: ${{ secrets.PAT_ME_REPO }} # use PAT to being able to push to protected branch later on
- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- run: echo "package=${{ matrix.package }}"
- name: Get pnpm store directory
id: pnpm-store
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-store.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: get directory for package
id: get-directory
run: |
directory=$(pnpm ls -r --json --filter $MATRIX_PACKAGE | jq -r '.[0] | .path')
directory="${directory##*/democracy-development/}"
# Ausgabe
echo "directory=$directory" >> $GITHUB_OUTPUT
echo "directory=$directory"
env:
MATRIX_PACKAGE: ${{ matrix.package }}
- name: Fetch tags
run: git fetch --tags
- name: Configure CI Git User
run: |
git config user.name "Manuel Ruck"
git config user.email "[email protected]"
git config push.followTags true
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Get changelog
id: get_changelog
run: |
changelog=''
if ( ${{ inputs.releaseVersion == 'auto' }} ); then
changelog=`pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --dry-run | sed -n '/^---$/,/^---$/p' | grep -v '^---$'`
else
changelog=`pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --release-as '${{ inputs.releaseVersion }}' --dry-run | sed -n '/^---$/,/^---$/p' | grep -v '^---$'`
fi
echo "$changelog"
echo "changelog=$changelog" >> $GITHUB_OUTPUT
# echo "$changelog" >> $GITHUB_STEP_SUMMARY
# echo "{${{ matrix.package }} v$changelog}" >> $GITHUB_STEP_SUMMARY
working-directory: ${{ steps.get-directory.outputs.directory }}
env:
MATRIX_PACKAGE: ${{ matrix.package }}
# - name: Determine next version number
# if: inputs.releaseVersion == 'auto'
# run: |
# nextVersion=`pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --dry-run | sed -n '/^---$/,/^---$/p' | grep -P -o '(\d+\.)(\d+\.)(\d)' | head -n 1`
# echo "$nextVersion"
# echo "NEXT_VERSION=$nextVersion" >> $GITHUB_ENV
# working-directory: ${{ steps.get-directory.outputs.directory }}
# env:
# MATRIX_PACKAGE: ${{ matrix.package }}
# - name: Manually next version number
# if: inputs.releaseVersion != 'auto'
# run: |
# echo "NEXT_VERSION=${{ inputs.releaseVersion }}" >> $GITHUB_ENV
# echo "$NEXT_VERSION"
# - name: bump version - DRY RUN
# if: inputs.dryRun == true
# run: |
# if ( ${{ inputs.releaseVersion == 'auto' }} ); then
# pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --dry-run
# else
# pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --release-as '${{ inputs.releaseVersion }}' --dry-run
# fi
# working-directory: ${{ steps.get-directory.outputs.directory }}
# env:
# MATRIX_PACKAGE: ${{ matrix.package }}
# - name: bump version - AUTOMATIC
# if: inputs.dryRun == false && inputs.releaseVersion == 'auto'
# run: pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v
# working-directory: ${{ steps.get-directory.outputs.directory }}
# env:
# MATRIX_PACKAGE: ${{ matrix.package }}
# - name: bump version - MANUAL VERSION NO.
# if: inputs.dryRun == false && inputs.releaseVersion != 'auto'
# run: pnpm dlx commit-and-tag-version --path . -t $MATRIX_PACKAGE@v --release-as '${{ inputs.releaseVersion }}'
# working-directory: ${{ steps.get-directory.outputs.directory }}
# env:
# MATRIX_PACKAGE: ${{ matrix.package }}
# - name: Publish tag # only possible on default branch
# if: inputs.dryRun == false
# run: |
# if ( ${{ contains(github.ref, github.event.repository.default_branch) }} ); then
# git push --follow-tags origin ${{ github.event.repository.default_branch }}
# else
# exit 1
# fi
# - name: Publish GitHub release
# uses: ncipollo/release-action@v1
# if: inputs.dryRun == false
# env:
# GITHUB_TOKEN: ${{ secrets.PAT }} # # use PAT to being able to push to protected branch later on
# with:
# tag: $NEXT_VERSION
# name: $NEXT_VERSION
# prerelease: true
# body: |
# ${{ steps.get_changelog.outputs.changelog }}