-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (99 loc) · 4.06 KB
/
Copy pathrelease.yml
File metadata and controls
115 lines (99 loc) · 4.06 KB
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
name: Release
on:
schedule:
- cron: "0 17 * * 2" # Weekly on Tuesday evenings
workflow_dispatch:
inputs:
dry-run:
description: Compute the next versions and release notes without publishing
type: boolean
default: false
permissions:
contents: read
concurrency:
group: release
jobs:
release:
name: Release ${{ matrix.package.name }}
runs-on: ubuntu-latest
permissions:
contents: write # create the tag and GitHub release
id-token: write # npm trusted publishing
strategy:
fail-fast: false
matrix:
package:
- name: gulp-browser-sync
path: plugins/gulp-browser-sync
- name: gulp-sharp
path: plugins/gulp-sharp
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
# Quoted so the shell running the action does not expand the glob
- name: Generate release notes
id: notes
uses: orhun/git-cliff-action@a9a95522b26fe6403f7bb24031f21fb573d0f5ff # v4.9.1
with:
args: --include-path '${{ matrix.package.path }}/**' --tag-pattern '^${{ matrix.package.name }}-v[0-9]+\.[0-9]+\.[0-9]+$' --unreleased --bump --strip all --output ${{ runner.temp }}/RELEASE_NOTES.md
# git-cliff reports the latest tag as the next version when nothing is releasable
- name: Check for releasable changes
id: check
env:
NOTES: ${{ runner.temp }}/RELEASE_NOTES.md
VERSION: ${{ steps.notes.outputs.version }}
run: |
if ! grep -q '[^[:space:]]' "$NOTES" || git rev-parse -q --verify "refs/tags/$VERSION" >/dev/null; then
echo "No releasable changes since the last release"
echo "release=false" >> "$GITHUB_OUTPUT"
else
{ echo "## $VERSION"; echo; cat "$NOTES"; } >> "$GITHUB_STEP_SUMMARY"
echo "release=true" >> "$GITHUB_OUTPUT"
fi
- name: Setup pnpm & Node.js
if: steps.check.outputs.release == 'true'
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
with:
runtime: node@latest
install: false
- name: Install dependencies
if: steps.check.outputs.release == 'true'
run: pnpm i --frozen-lockfile
- name: Build package
if: steps.check.outputs.release == 'true'
run: pnpm --filter "./${{ matrix.package.path }}" build
- name: Set package version
if: steps.check.outputs.release == 'true'
working-directory: ${{ matrix.package.path }}
env:
VERSION: ${{ steps.notes.outputs.version }}
run: pnpm version "${VERSION##*-v}" --no-git-tag-version --allow-same-version
# pnpm publishes via npm trusted publishing (OIDC) itself; the runner's npm is too old for it
# Skipping an already published version lets a failed run be retried safely
# Waiting for the version to be installable keeps the GitHub release from getting ahead of npm
- name: Publish package
if: steps.check.outputs.release == 'true'
working-directory: ${{ matrix.package.path }}
env:
DRY_RUN: ${{ inputs.dry-run }}
VERSION: ${{ steps.notes.outputs.version }}
run: |
name="$(jq -r .name package.json)"
if [[ "$DRY_RUN" == "true" ]]; then
pnpm publish --no-git-checks --dry-run
elif [[ -n "$(pnpm view "$name@${VERSION##*-v}" version 2>/dev/null)" ]]; then
echo "$name@${VERSION##*-v} is already published"
else
pnpm publish --no-git-checks --publish-wait-timeout 600000
fi
- name: Create GitHub release
if: steps.check.outputs.release == 'true' && !inputs.dry-run
env:
GH_TOKEN: ${{ github.token }}
NAME: ${{ matrix.package.name }}
NOTES: ${{ runner.temp }}/RELEASE_NOTES.md
VERSION: ${{ steps.notes.outputs.version }}
run: |
gh release create "$VERSION" --target "$GITHUB_SHA" --title "$NAME: v${VERSION##*-v}" --notes-file "$NOTES"