-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (133 loc) · 4.74 KB
/
Copy pathpublish.yml
File metadata and controls
158 lines (133 loc) · 4.74 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Publish packages to NPM
on:
workflow_dispatch:
pull_request:
types:
- closed
branches:
- master
- dev
workflow_run:
workflows:
- Update API client
- Update API client (dev)
types:
- completed
permissions:
id-token: write
contents: read
jobs:
publish:
if:
(github.event.workflow_run.name == 'Update API client' || github.event.pull_request.base.ref == 'master') &&
(github.event.pull_request.merged == true || github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-latest
env:
PUBLISH_PAT: ${{ secrets.PUBLISH_PAT }}
GH_TOKEN: ${{ secrets.PUBLISH_PAT }}
steps:
- name: Checkout ⬇️
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.PUBLISH_PAT }}
- name: Setup Node 🎛️
uses: actions/setup-node@v6
with:
node-version: 24
cache: "yarn"
registry-url: "https://registry.npmjs.org"
- name: Git Identity 🪪
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Yarn Install 📦️
run: yarn install --immutable
- name: Setup NX 1/2 🎛️
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: master
# This step is needed for nx affected to work when CI is running on a PR
# See also https://nx.dev/ci/recipes/set-up/monorepo-ci-github-actions#configuring-ci-using-github-actions-and-nx
- name: Setup NX 2/2 🎛
if:
(github.ref != 'refs/heads/master' &&
github.event.workflow_run.head_branch != 'master')
run: git branch --track master origin/master
- name: Build 🔨
run: yarn nx affected -t build --parallel=3
# TODO: Uses the previous version. Needs a fix!
- name: Create version file 🔢
run: |
yarn nx run @mittwald/api-client:build:write-version-file
git add .
- name: Version and publish 🚀
if:
github.event.workflow_run.head_branch == 'master' || github.ref ==
'refs/heads/master'
run: |
git describe --exact-match --tags || code=$?
if [ "${code:-0}" -eq 128 ]; then
yarn lerna publish \
--message "chore(release): bump version to %v" \
--skip-bump-only-releases \
--conventional-commits \
--create-release github \
--yes --no-private \
--tag-version-prefix ""
fi
publish-dev:
if:
github.event.workflow_run.name == 'Update API client (dev)' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
env:
PUBLISH_PAT: ${{ secrets.PUBLISH_PAT }}
GH_TOKEN: ${{ secrets.PUBLISH_PAT }}
steps:
- name: Checkout ⬇️
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.PUBLISH_PAT }}
ref: ${{ github.event.workflow_run.head_branch }}
- name: Setup Node 🎛️
uses: actions/setup-node@v6
with:
node-version: 24
cache: "yarn"
registry-url: "https://registry.npmjs.org"
- name: Git Identity 🪪
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Yarn Install 📦️
run: yarn install --immutable
- name: Setup NX 1/2 🎛️
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: dev
# This step is needed for nx affected to work when CI is running on a PR
# See also https://nx.dev/ci/recipes/set-up/monorepo-ci-github-actions#configuring-ci-using-github-actions-and-nx
- name: Setup NX 2/2 🎛
if:
(github.ref != 'refs/heads/dev' &&
github.event.workflow_run.head_branch != 'dev')
run: git branch --track dev origin/dev
- name: Build 🔨
run: yarn nx affected -t build --parallel=3
# TODO: Uses the previous version. Needs a fix!
- name: Create version file 🔢
run: |
yarn nx run @mittwald/api-client:build:write-version-file
git add .
- name: Version and publish 🚀
run: |
git describe --exact-match --tags || code=$?
if [ "${code:-0}" -eq 128 ]; then
yarn lerna publish 0.0.0-development-$(git rev-parse --short=7 HEAD)-$(date +%Y%m%d) \
--message "chore(release): bump version to %v" \
--skip-bump-only-releases \
--yes --no-private \
--tag-version-prefix "" \
--dist-tag development
fi