Skip to content

Commit 300749b

Browse files
authored
CI: update pipelines (#29)
* chore: bump .npmrc * ci: update pull request automation * ci: pre-release manual action * ci: fix pull request actions dependencies * ci: fix pnpm cache key output * ci: fix release to use lib/package.json * ci: fix pre-release for monorepo lib * add to project board * fix: ci release branch * change default build to node lts * change ci node matrix syntax * CI: update default node to rolling LTS
1 parent 18cf923 commit 300749b

File tree

6 files changed

+256
-54
lines changed

6 files changed

+256
-54
lines changed

.github/workflows/add-to-project.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Add new item to project board
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
pull_request_target:
8+
types:
9+
- opened
10+
11+
jobs:
12+
add-to-project:
13+
uses: unleash/.github/.github/workflows/add-item-to-project.yml@main
14+
secrets: inherit

.github/workflows/branch.yml

-21
This file was deleted.

.github/workflows/pre-release.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 🚀 Bump pre-release version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
preid:
7+
description: "Prerelease ID"
8+
required: true
9+
default: "alpha"
10+
type: choice
11+
options:
12+
- alpha
13+
- beta
14+
- rc
15+
16+
jobs:
17+
bump-chore:
18+
name: Chore
19+
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
shell: bash
23+
24+
steps:
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version: 'lts/*'
28+
registry-url: "https://registry.npmjs.org"
29+
30+
- uses: pnpm/action-setup@v2
31+
id: pnpm-install
32+
with:
33+
version: 7
34+
run_install: false
35+
36+
- uses: actions/checkout@v3
37+
with:
38+
token: ${{ secrets.GH_ACCESS_TOKEN }}
39+
fetch-depth: 2
40+
41+
- name: ⚙️ Update version
42+
run: |
43+
cd lib
44+
pnpm version --preid ${{ github.event.inputs.preid }} --git-tag-version=false prerelease || true
45+
# ` || true` - pnpm will return error because of monorepository dev dependencies
46+
47+
- id: Commit
48+
run: |
49+
git config user.name github-actions
50+
git config user.email github-actions@github.com
51+
PACKAGE_VERSION=$(node -p "require('./lib/package.json').version")
52+
git commit -am "chore: v${PACKAGE_VERSION}"
53+
54+
- run: git push

.github/workflows/pull_request.yml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: 📋 Verify pull requests
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
steps:
14+
- uses: actions/setup-node@v3
15+
id: setup-node
16+
with:
17+
node-version: 'lts/*'
18+
19+
- uses: pnpm/action-setup@v2
20+
id: pnpm-install
21+
with:
22+
version: 7
23+
run_install: false
24+
25+
- uses: actions/checkout@v3
26+
id: setup-git-checkout
27+
with:
28+
fetch-depth: 25
29+
30+
- id: pnpm-cache-path
31+
run: |
32+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
33+
34+
- uses: actions/cache@v3
35+
name: 🗄️ Setup pnpm cache
36+
with:
37+
path: ${{ steps.pnpm-cache-path.outputs.STORE_PATH }}
38+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
39+
restore-keys: |
40+
${{ runner.os }}-pnpm-store-
41+
42+
- name: 📌 Install dependencies
43+
run: pnpm install --frozen-lockfile --strict-peer-dependencies
44+
45+
- name: 🔨 Build
46+
run: pnpm build
47+
48+
- uses: actions/cache@v3
49+
name: 🗃️ Cache build
50+
timeout-minutes: 10
51+
id: cache-build
52+
with:
53+
path: ./*
54+
key: ${{ github.sha }}-${{ github.run_number }}
55+
56+
test:
57+
runs-on: ubuntu-latest
58+
needs: build
59+
defaults:
60+
run:
61+
shell: bash
62+
strategy:
63+
matrix:
64+
node-version: [16.x, 18.x, 19.x]
65+
66+
steps:
67+
- uses: actions/setup-node@v3
68+
with:
69+
node-version: ${{ matrix.node-version }}
70+
71+
- uses: pnpm/action-setup@v2
72+
id: pnpm-install
73+
with:
74+
version: 7
75+
run_install: false
76+
77+
- uses: actions/cache@v3
78+
name: 🗃️ Restore build cache
79+
timeout-minutes: 5
80+
id: restore-build
81+
with:
82+
path: ./*
83+
key: ${{ github.sha }}-${{ github.run_number }}
84+
85+
- name: 🧪 Tests
86+
run: pnpm test
87+
88+
lint:
89+
runs-on: ubuntu-latest
90+
needs: build
91+
defaults:
92+
run:
93+
shell: bash
94+
steps:
95+
- uses: actions/setup-node@v3
96+
with:
97+
node-version: 'lts/*'
98+
99+
- uses: pnpm/action-setup@v2
100+
id: pnpm-install
101+
with:
102+
version: 7
103+
run_install: false
104+
105+
- uses: actions/cache@v3
106+
name: 🗃️ Restore build cache
107+
timeout-minutes: 5
108+
id: restore-build
109+
with:
110+
path: ./*
111+
key: ${{ github.sha }}-${{ github.run_number }}
112+
113+
- name: ✨ Lint
114+
run: pnpm lint

.github/workflows/release.yml

+73-32
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,88 @@
1-
name: Publish
1+
name: 🚂 NPM & GitHub Release
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- lib/package.json
69

710
jobs:
8-
publish:
9-
if: "!github.event.release.prerelease"
11+
build-test-release:
12+
name: Release train choo choo
1013
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
shell: bash
17+
1118
steps:
12-
- uses: actions/checkout@v3
13-
- uses: pnpm/action-setup@v2
14-
with:
15-
version: 7
1619
- uses: actions/setup-node@v3
20+
id: setup-node
1721
with:
1822
node-version: 18
19-
cache: "pnpm"
20-
registry-url: https://registry.npmjs.org/
21-
- run: pnpm install
22-
- run: pnpm build
23-
- run: pnpm lint
24-
- run: pnpm test
25-
- run: cd lib && pnpm publish --no-git-checks
26-
env:
27-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28-
pre-publish:
29-
if: "github.event.release.prerelease"
30-
runs-on: ubuntu-latest
31-
steps:
23+
registry-url: "https://registry.npmjs.org"
24+
3225
- uses: actions/checkout@v3
26+
id: setup-git-checkout
27+
with:
28+
token: ${{ secrets.GH_ACCESS_TOKEN }}
29+
fetch-depth: 2
30+
3331
- uses: pnpm/action-setup@v2
32+
id: pnpm-install
3433
with:
3534
version: 7
36-
- uses: actions/setup-node@v3
37-
with:
38-
node-version: 18
39-
cache: "pnpm"
40-
registry-url: https://registry.npmjs.org/
41-
- run: pnpm install
42-
- run: pnpm build
43-
- run: pnpm lint
44-
- run: pnpm test
45-
- run: cd lib && pnpm publish --no-git-checks --tag next
35+
run_install: |
36+
- recursive: true
37+
args: [--frozen-lockfile, --strict-peer-dependencies]
38+
39+
- name: 🔍️ Get version from lib/package.json
40+
run: |
41+
PACKAGE_VERSION=$(node -p "require('./lib/package.json').version")
42+
PACKAGE_TAG=$(node -p "/^\d(?:\.\d)*\-([\w\-]+)[\.\+]?.*$/.exec('$PACKAGE_VERSION')?.[1] ?? 'latest'")
43+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
44+
echo "PACKAGE_TAG=$PACKAGE_TAG" >> $GITHUB_ENV
45+
46+
- name: 🔨 Build
47+
run: pnpm build
48+
49+
- name: ✨ Lint
50+
run: pnpm lint
51+
52+
- name: 🧪 Tests
53+
run: pnpm test
54+
55+
- name: 🔖 Create git tag
56+
run: |
57+
git config user.name github-actions
58+
git config user.email github-actions@github.com
59+
git tag v$PACKAGE_VERSION
60+
git push --tags
61+
62+
- name: 📦️ Publish to NPM
63+
run: pnpm publish --access public --tag $PACKAGE_TAG
4664
env:
4765
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
66+
67+
- name: 📝 Publish GitHub Release
68+
env:
69+
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
70+
run: |
71+
WORKFLOW_RELEASE_PRERELEASE=$(node -p "'$PACKAGE_TAG' !== 'latest'")
72+
WORKFLOW_RELEASE_BODY=$(
73+
cat <<-_EOT_
74+
{
75+
"tag_name": "v${PACKAGE_VERSION}",
76+
"name": "v${PACKAGE_VERSION}",
77+
"prerelease": ${WORKFLOW_RELEASE_PRERELEASE},
78+
"generate_release_notes": true
79+
}
80+
_EOT_
81+
)
82+
curl -L --fail-with-body \
83+
-X POST \
84+
-H "Accept: application/vnd.github+json" \
85+
-H "Authorization: Bearer $GH_ACCESS_TOKEN" \
86+
-H "X-GitHub-Api-Version: 2022-11-28" \
87+
"https://api.github.com/repos/$GITHUB_REPOSITORY/releases" \
88+
-d "$WORKFLOW_RELEASE_BODY"

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.13.0
1+
v19.7.0

0 commit comments

Comments
 (0)