-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (127 loc) · 5.46 KB
/
release-please.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
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
name: Release Please
on:
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
push:
branches:
- main
env:
# Set to 'alpha', 'beta', or 'rc' to create a prerelease.
PRERELEASE: 'alpha'
MAJOR_VERSION: 12
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Next release
if: ${{ env.PRERELEASE != 'false' }}
id: next-release
run: |
# Log commands and exit on error.
set -exo pipefail
if [[ "${PRERELEASE}" != "alpha" && "${PRERELEASE}" != "beta" && "${PRERELEASE}" != "rc" ]]; then
echo "Invalid PRERELEASE value. Must be 'alpha', 'beta', or 'rc'."
exit 1
fi
# Get the current prerelease version.
ACC="Accept: application/vnd.github+json"
VER="X-GitHub-Api-Version: 2022-11-28"
JSON='map(.tag_name) | [.[] | select(startswith("${{ env.MAJOR_VERSION }}.")) ] | .[0] // empty'
CURRENT_RELEASE=$(gh api -H "${ACC}" -H "${VER}" /repos/${{ github.repository }}/releases | jq -r "${JSON}")
# Bump the prerelease version.
if [[ -z "$CURRENT_RELEASE" || "$CURRENT_RELEASE" != "${{ env.MAJOR_VERSION }}.0.0-${{ env.PRERELEASE }}."* ]]; then
NEXT_VERSION="${{ env.MAJOR_VERSION }}.0.0-${{ env.PRERELEASE }}.0"
else
NEXT_VERSION=$(npx --yes semver -i prerelease $CURRENT_RELEASE)
fi
# If version is empty, exit.
if [ -z "$NEXT_VERSION" ]; then
echo "Not able to determine prerelease version."
exit 1
fi
echo "Next release version: $NEXT_VERSION"
echo "next-release=$NEXT_VERSION" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
- uses: google-github-actions/release-please-action@v3
id: release
with:
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"deprecation","section":"Deprecations","hidden":false}]'
release-type: 'node'
default-branch: '${{ github.ref_name }}'
package-name: 'stache'
pull-request-title-pattern: 'chore: release ${version}'
labels: 'autorelease ${{ github.ref_name }}: pending'
release-labels: 'autorelease ${{ github.ref_name }}: tagged'
release-as: '${{ steps.next-release.outputs.next-release }}'
prerelease: ${{ env.PRERELEASE != 'false' }}
draft-pull-request: true
include-v-in-tag: false
token: '${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}'
- uses: actions/checkout@v4
with:
token: '${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}'
- uses: actions/setup-node@v4
id: setup-node
with:
node-version-file: '.nvmrc'
# Workaround to avoid "Post Run actions/setup-node" failures.
# See: https://github.com/actions/setup-node/issues/317
- name: Ensure cache directory exists
if: ${{ !steps.release.outputs.release_created }}
run: mkdir -p /home/runner/.npm
continue-on-error: true
- name: Cache node modules
if: ${{ steps.release.outputs.release_created }}
id: cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ steps.setup-node.outputs.node-version }}-modules-${{ hashFiles('package-lock.json') }}
- name: npm install
if: ${{ steps.release.outputs.release_created && steps.cache.outputs.cache-hit != 'true' }}
run: npm ci
- name: Build
if: ${{ steps.release.outputs.release_created }}
run: npx skyux-dev create-packages-dist --skipNxCache
- name: Publish
if: ${{ steps.release.outputs.release_created }}
run: npx skyux-dev publish-packages-dist
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Capture logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: npm-logs
path: /home/runner/.npm/_logs
retention-days: 3
- name: Notify Slack (success)
if: ${{ steps.release.outputs.release_created }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: Successfully published Stache ${{ steps.release.outputs.tag_name }} to NPM. http://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md
SLACK_ICON: https://github.com/blackbaud.png?size=48
SLACK_USERNAME: Stache
- name: Notify Slack (failure)
if: ${{ failure() && steps.release.outputs.release_created }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ job.status }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: Failed to publish Stache ${{ steps.release.outputs.tag_name }} to NPM!
SLACK_ICON: https://github.com/blackbaud.png?size=48
SLACK_USERNAME: Stache
- name: Notify Slack (failure, non-release)
if: ${{ failure() && !steps.release.outputs.release_created }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ job.status }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: Failed when preparing Stache release!
SLACK_ICON: https://github.com/blackbaud.png?size=48
SLACK_USERNAME: Stache
#cor-skyux-notifications
SLACK_CHANNEL: C01GY7ZP4HM