-
Notifications
You must be signed in to change notification settings - Fork 4
70 lines (61 loc) · 2.08 KB
/
release-lib.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
name: Release litlytics library
on:
workflow_run:
# Run after "Test and lint" workflow
workflows: ['Test and lint']
types:
- completed # Only when it's completed
branches:
- main # Only run the publish workflow for pushes to main
jobs:
publish-lib:
environment: Github CI
# Only proceed if the tests passed and we're on release
if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
# Check for changes in ./packages/litlytics
- name: Check if changed
id: changes
run: |
# Check if any files changed in the specified directory
if git diff --quiet HEAD^ HEAD ./packages/litlytics; then
echo "No changes in ./packages/litlytics. Skipping publish."
echo "should_publish=false" >> $GITHUB_ENV
else
echo "Changes detected in ./packages/litlytics."
echo "should_publish=true" >> $GITHUB_ENV
fi
# install node (for npm utils)
- name: Install node for npm checks
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
# install bun
- name: Install bun for deployment
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
# Install dependencies
- name: Install dependencies
working-directory: ./packages/litlytics
run: bun install --frozen-lockfile
# Build package
- name: Build package
working-directory: ./packages/litlytics
run: bun run build
# install and publish if local version is not the same as published
- name: publish
if: ${{ env.should_publish == 'true' }}
working-directory: ./packages/litlytics
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}