forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (81 loc) · 3.26 KB
/
release-nightly.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
name: 🌒 Nightly Release
on:
workflow_dispatch:
schedule:
- cron: "0 7 * * *" # every day at 12AM PST
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CI: true
jobs:
# HEADS UP! this "nightly" job will only ever run on the `main` branch due to
# it being a cron job, and the last commit on main will be what github shows
# as the trigger however in the checkout below we specify the `dev` branch,
# so all the scripts in this job will be ran from that, confusing i know, so
# in some cases we'll need to create multiple PRs when modifying nightly
# release processes
nightly:
name: 🌒 Nightly Release
if: github.repository == 'remix-run/react-router'
runs-on: ubuntu-latest
outputs:
# allows this to be used in the `comment` job below - will be undefined
# if there's no release necessary
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
ref: dev
# checkout using a custom token so that we can push later on
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: 📥 Install deps
run: pnpm install --frozen-lockfile
- name: 🕵️ Check for changes
id: version
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
# get latest nightly tag
LATEST_NIGHTLY_TAG=$(git tag -l v0.0.0-nightly-\* --sort=-creatordate | head -n 1)
# check if last commit to dev starts with the nightly tag we're about
# to create (minus the date)
# if it is, we'll skip the nightly creation
# if not, we'll create a new nightly tag
if [[ ${LATEST_NIGHTLY_TAG} == v0.0.0-nightly-${SHORT_SHA}-* ]]; then
echo "🛑 Latest nightly tag is the same as the latest commit sha, skipping nightly release"
else
# yyyyMMdd format (e.g. 20221207)
DATE=$(date '+%Y%m%d')
# v0.0.0-nightly-<short sha>-<date>
NEXT_VERSION=0.0.0-nightly-${SHORT_SHA}-${DATE}
# set output so it can be used in other jobs
echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_OUTPUT
fi
- name: ⤴️ Update version
if: steps.version.outputs.NEXT_VERSION
run: |
git config --local user.email "[email protected]"
git config --local user.name "Remix Run Bot"
git checkout -b nightly/${{ steps.version.outputs.NEXT_VERSION }}
pnpm run version ${{steps.version.outputs.NEXT_VERSION}}
git push origin --tags
- name: 🏗 Build
if: steps.version.outputs.NEXT_VERSION
run: pnpm build
- name: 🔐 Setup npm auth
if: steps.version.outputs.NEXT_VERSION
run: |
echo "registry=https://registry.npmjs.org" >> ~/.npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- name: 🚀 Publish
if: steps.version.outputs.NEXT_VERSION
run: pnpm run publish