Skip to content

Commit 0e84377

Browse files
committed
ci: add Publish workflow
1 parent f89ee89 commit 0e84377

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/publish.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Publish
2+
3+
# Roughly based on https://github.com/nrwl/ci/blob/main/.github/workflows/nx-cloud-main.yml
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
# The name of the job which will invoke this one is expected to be "Publish", and whatever we call this will be appended
14+
# to that one after a forward slash, so we keep this one intentionally short to produce "Publish / Run" in the Github UI
15+
name: Run
16+
defaults:
17+
run:
18+
working-directory: ${{ github.workspace }}
19+
# Specify shell to help normalize across different operating systems
20+
shell: bash
21+
steps:
22+
- uses: actions/checkout@v3
23+
name: Checkout
24+
with:
25+
# We need to fetch all branches and commits so that Lerna has a base to compare against.
26+
fetch-depth: 0
27+
28+
# Set node/npm/yarn versions using volta, with optional overrides provided by the consumer
29+
- uses: volta-cli/action@v4
30+
31+
# Install pnpm with exact version provided by consumer or fallback to latest
32+
- name: Install PNPM
33+
uses: pnpm/action-setup@v2
34+
35+
- name: Print node/npm/yarn versions
36+
id: versions
37+
run: |
38+
node_ver=$( node --version )
39+
yarn_ver=$( yarn --version || true )
40+
pnpm_ver=$( pnpm --version || true )
41+
42+
echo "Node: ${node_ver:1}"
43+
echo "NPM: $( npm --version )"
44+
if [[ $yarn_ver != '' ]]; then echo "Yarn: $yarn_ver"; fi
45+
if [[ $pnpm_ver != '' ]]; then echo "PNPM: $pnpm_ver"; fi
46+
47+
echo "node_version=${node_ver:1}" >> $GITHUB_OUTPUT
48+
echo "yarn_version=${yarn_ver}" >> $GITHUB_OUTPUT
49+
50+
- name: Get pnpm cache directory path
51+
id: pnpm-cache-dir-path
52+
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT
53+
54+
- name: Use the node_modules cache if available
55+
uses: actions/cache@v3
56+
with:
57+
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
58+
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
59+
restore-keys: |
60+
${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-
61+
62+
- name: Install dependencies
63+
run: |
64+
echo "Running pnpm install --frozen-lockfile"
65+
pnpm install --frozen-lockfile
66+
67+
- name: Import GPG key
68+
uses: crazy-max/ghaction-import-gpg@v5
69+
with:
70+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
71+
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
72+
git_user_signingkey: true
73+
git_commit_gpgsign: true
74+
git_tag_gpgsign: true
75+
76+
- name: Publish
77+
env:
78+
"GH_TOKEN": ${{ secrets.GITHUB_TOKEN }}
79+
"npm_config_//registry.npmjs.org/:_authToken": ${{ secrets.NPM_TOKEN }}
80+
run: |
81+
echo "Running pnpm lerna publish --yes"
82+
pnpm lerna publish --yes

0 commit comments

Comments
 (0)