Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/actions/cached-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
caching:
description: Whether to cache dependencies or not
required: false
default: 'true'
default: "true"
outputs:
used-cache:
description: Whether the cache was used
Expand All @@ -31,9 +31,3 @@ runs:
yarn install --frozen-lockfile
echo "cache='${{ inputs.caching }}'" >> $GITHUB_OUTPUT
shell: bash

- name: Postinstall
if: steps.cache.outputs.cache-hit == 'true' && inputs.caching == 'true'
id: postinstall
run: yarn postinstall
shell: bash
78 changes: 78 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build & Publish

on:
push:
tags:
- "v*"

permissions:
id-token: write # Required for OIDC
contents: read
packages: write

jobs:
install-and-build:
name: 🛠️ Install & Build
runs-on: ubuntu-latest

steps:
- name: 🗜️ Checkout
uses: actions/checkout@v6

- name: 🗜️ Setup node version
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"

- name: 🗜️ Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.2

- name: 🛠️ Install
uses: ./.github/actions/cached-deps

- name: 🛠️ Clean temporary files
run: yarn clean

- name: 📦 Build
run: yarn build

- name: 🛠️ Setup package
run: yarn script:package-npm

- name: 🛠️ Copy files to dist
run: yarn copy-files

- name: 🚀 Publish NPM
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'beta') == false
run: cd dist && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

- name: 🚀 Publish NPM BETA
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'beta') == true
run: cd dist && npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

- name: 🛠️ Set up package for GPR
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'beta') == false
run: yarn script:package-github

- name: 🛠️ Use GPR
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'beta') == false
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://npm.pkg.github.com/
scope: "@celtian"

- name: 🚀 Publish to GitHub Package Registry
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'beta') == false
run: |
cd dist
npm publish
env:
NODE_AUTH_TOKEN: ${{github.token}}
37 changes: 37 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test PR
"on": pull_request

jobs:
install-and-test:
name: 🛠️ Install & Test
runs-on: ubuntu-latest

steps:
- name: 🗜️ Checkout
uses: actions/checkout@v6

- name: 🗜️ Setup node version
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"

- name: 🗜️ Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.2

- name: 🛠️ Install
uses: ./.github/actions/cached-deps

- name: 🛠️ Clean temporary files
run: yarn clean

- name: 📦 Build
run: yarn build

- name: 🛠️ Setup package
run: yarn script:package-npm

- name: 🛠️ Copy files to dist
run: yarn copy-files
6 changes: 4 additions & 2 deletions scripts/package-github.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writeFileSync } from 'fs-extra';
import { ensureDirSync, writeFileSync } from 'fs-extra';
import { join, resolve } from 'path';

const pkg = require(resolve(__dirname, '..', 'package.json'));
Expand All @@ -17,6 +17,8 @@ pkg.publishConfig = {
registry: 'https://npm.pkg.github.com'
};

writeFileSync(join(__dirname, '..', 'dist', 'package.json'), JSON.stringify(pkg, null, 2));
const distDir = join(__dirname, '..', 'dist');
ensureDirSync(distDir);
writeFileSync(join(distDir, 'package.json'), JSON.stringify(pkg, null, 2));

console.log('\x1b[34m', `Package.json in dist/ modified with publishConfig and name.`, '\x1b[0m');
6 changes: 4 additions & 2 deletions scripts/package-npm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writeFileSync } from 'fs-extra';
import { writeFileSync, ensureDirSync } from 'fs-extra';
import { join, resolve } from 'path';

const pkg = require(resolve(__dirname, '..', 'package.json'));
Expand All @@ -12,7 +12,9 @@ pkg.bin = {
"version-info": "bin/version_info"
};

writeFileSync(join(__dirname, '..', 'dist', 'package.json'), JSON.stringify(pkg, null, 2));
const distDir = join(__dirname, '..', 'dist');
ensureDirSync(distDir);
writeFileSync(join(distDir, 'package.json'), JSON.stringify(pkg, null, 2));

console.log('\x1b[34m', 'Package.json in dist/ modified.', '\x1b[0m');

Expand Down