Skip to content

Commit 00d9b9c

Browse files
committed
Fix litlytics lib prerelease and release github ci workflows
1 parent 0a54a31 commit 00d9b9c

File tree

2 files changed

+45
-60
lines changed

2 files changed

+45
-60
lines changed

.github/workflows/prerelease-lib.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ on:
1212
jobs:
1313
publish-lib:
1414
environment: Github CI
15-
if: ${{ github.event.workflow_run.conclusion == 'success' }} # Only proceed if the tests passed
15+
# Only proceed if the tests passed and we're not on release
16+
if: ${{ github.event.workflow_run.conclusion == 'success' }} && startsWith(github.head_ref, 'refs/tags/') == false
1617
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
id-token: write
1721

1822
steps:
1923
- name: Checkout repository
@@ -37,6 +41,7 @@ jobs:
3741
uses: actions/setup-node@v4
3842
with:
3943
node-version: 22
44+
registry-url: 'https://registry.npmjs.org'
4045

4146
# install bun
4247
- name: Install bun for deployment

.github/workflows/release-lib.yml

+39-59
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Images
1+
name: Prerelease litlytics library
22

33
on:
44
workflow_run:
@@ -9,80 +9,60 @@ on:
99
branches:
1010
- main # Only run the publish workflow for pushes to main
1111

12-
env:
13-
# Use docker.io for Docker Hub if empty
14-
REGISTRY: ghcr.io
15-
# github.repository as <account>/<repo>
16-
IMAGE_NAME: ${{ github.repository }}
17-
1812
jobs:
19-
build:
13+
publish-lib:
2014
environment: Github CI
15+
# Only proceed if the tests passed and we're on release
16+
if: ${{ github.event.workflow_run.conclusion == 'success' }} && startsWith(github.head_ref, 'refs/tags/') == true
2117
runs-on: ubuntu-latest
2218
permissions:
2319
contents: read
24-
packages: write
2520
id-token: write
2621

2722
steps:
2823
- name: Checkout repository
2924
uses: actions/checkout@v4
3025

31-
- name: Install bun for deployment
32-
uses: oven-sh/setup-bun@v2
33-
with:
34-
bun-version: latest
35-
36-
# Login against a Docker registry
37-
# https://github.com/docker/login-action
38-
- name: Log into registry ${{ env.REGISTRY }}
39-
uses: docker/login-action@v3
40-
with:
41-
registry: ${{ env.REGISTRY }}
42-
username: ${{ github.actor }}
43-
password: ${{ secrets.GITHUB_TOKEN }}
44-
45-
# Extract metadata (tags, labels) for Docker
46-
# https://github.com/docker/metadata-action
47-
- name: Extract Docker metadata
48-
id: meta
49-
uses: docker/metadata-action@v5
50-
with:
51-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52-
53-
# Conditional tagging based on the event type (main push or release)
54-
- name: Determine image tags
55-
id: tags
26+
# Check for changes in ./packages/litlytics
27+
- name: Check if changed
28+
id: changes
5629
run: |
57-
if [[ "${{ github.event_name }}" == "release" ]]; then
58-
# Tag as `latest` and `vX.X.X` for releases
59-
echo "TAGS=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}" >> $GITHUB_ENV
30+
# Check if any files changed in the specified directory
31+
if git diff --quiet HEAD^ HEAD ./packages/litlytics; then
32+
echo "No changes in ./packages/litlytics. Skipping publish."
33+
echo "should_publish=false" >> $GITHUB_ENV
6034
else
61-
# Tag as `nightly` for pushes to main
62-
echo "TAGS=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly" >> $GITHUB_ENV
35+
echo "Changes detected in ./packages/litlytics."
36+
echo "should_publish=true" >> $GITHUB_ENV
6337
fi
64-
shell: bash
6538
66-
# Build and push Docker image with Buildx
67-
# https://github.com/docker/build-push-action
68-
- name: Build and push Docker image
69-
id: build-and-push
70-
uses: docker/build-push-action@v6
39+
# install node (for npm utils)
40+
- name: Install node for npm checks
41+
uses: actions/setup-node@v4
7142
with:
72-
push: true
73-
tags: ${{ env.TAGS }}
74-
labels: ${{ steps.meta.outputs.labels }}
43+
node-version: 22
44+
registry-url: 'https://registry.npmjs.org'
7545

76-
# deploy nightly
77-
- name: Deploy docker image to staging
78-
if: github.event_name != 'release'
79-
env:
80-
EXO_TOKEN: ${{ secrets.EXO_TOKEN }}
81-
run: bunx exoframe -u -c exoframe-nightly.json -e https://exoframe.codezen.net -t $EXO_TOKEN
46+
# install bun
47+
- name: Install bun for deployment
48+
uses: oven-sh/setup-bun@v2
49+
with:
50+
bun-version: latest
51+
52+
# Install dependencies
53+
- name: Install dependencies
54+
working-directory: ./packages/litlytics
55+
run: bun install --frozen-lockfile
56+
57+
# Build package
58+
- name: Build package
59+
working-directory: ./packages/litlytics
60+
run: bun run build
8261

83-
# deploy to prod
84-
- name: Deploy docker image to production
85-
if: github.event_name == 'release'
62+
# install and publish if local version is not the same as published
63+
- name: publish
64+
if: ${{ env.should_publish == 'true' }}
65+
working-directory: ./packages/litlytics
66+
run: npm publish --access public
8667
env:
87-
EXO_TOKEN: ${{ secrets.EXO_TOKEN }}
88-
run: bunx exoframe -u -e https://exoframe.codezen.net -t $EXO_TOKEN
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)