forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (96 loc) · 3.78 KB
/
publish-release-candidate.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
name: 🏎 Publish Release Candidate
on:
push:
branches: ['release/**']
# We don't want this to run on release
tags-ignore: ['v**']
# No need to run on docs-only changes
paths-ignore: ['docs/**']
# Cancel in-progress runs of this workflow.
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-git-tags:
name: 🏷 Check git tags
if: github.repository == 'redwoodjs/redwood'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Required because lerna uses tags to determine the version.
with:
fetch-depth: 0
- name: Enable Corepack
run: corepack enable
- name: ⬢ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: 🏷 Check git tags
run: |
CURRENT_TAG=$(git describe --abbrev=0)
# `github.ref_name` is something like `release/minor/v1.1.0`.
# `basename` gets us `v1.1.0`, then parameter expansion strips the `v`.
# See https://stackoverflow.com/questions/6594085/remove-first-character-of-a-string-in-bash.
BRANCH_TAG=$(basename ${{ github.ref_name }})
echo
echo "Current tag is $CURRENT_TAG"
echo "Branch tag is $BRANCH_TAG"
echo "Comparing tags with \"yarn dlx semver-compare-cli $CURRENT_TAG lt $BRANCH_TAG\""
echo
# See if the current tag is less than the branch's tag.
# If it is, we're good to keep going.
yarn dlx semver-compare-cli $CURRENT_TAG lt $BRANCH_TAG
publish-release-candidate:
name: 🚢 Publish Release Candidate
needs: check-git-tags
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.value }}
steps:
- uses: actions/checkout@v4
with:
# `fetch-depth`—number of commits to fetch. `0` fetches all history for all branches and tags.
# This is required because lerna uses tags to determine the version.
fetch-depth: 0
- name: Set up job
uses: ./.github/actions/set-up-job
- name: 🔎 Lint
run: yarn lint
- name: 🧪 Test
run: yarn test
- name: 🚢 Publish
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
SEMVER=$(basename $(dirname ${{ github.ref_name }}))
yarn lerna publish pre$SEMVER --include-merged-tags \
--exact \
--canary \
--preid rc \
--dist-tag rc \
--force-publish \
--loglevel verbose \
--no-git-reset \
--yes
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: 🏷 Get version
id: get-version
uses: sergeysova/[email protected]
with:
cmd: 'jq .version packages/core/package.json -r'
message-slack:
name: 💬 Message Slack
needs: publish-release-candidate
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 💬 Message Slack
uses: ./.github/actions/message_slack_publishing
with:
title: "🏎 RC Packages"
status: ${{ needs.publish-release-candidate.result }}
version: ${{ needs.publish-release-candidate.outputs.version }}
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_PACKAGE_PUBLISHING }}