Skip to content

chore: add docker build #14

chore: add docker build

chore: add docker build #14

Workflow file for this run

name: Release and Publish
on:
push:
branches:
- main
permissions:
contents: write
packages: write
jobs:
version-bump:
name: Bump Version
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.bump.outputs.new_version }}
new_tag: ${{ steps.bump.outputs.new_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
id: bump
run: |
cd cli
npm version patch --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "new_tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
cd ..
# Update root package.json version to match
npm version $NEW_VERSION --no-git-tag-version --allow-same-version
git add cli/package.json package.json package-lock.json cli/package-lock.json
git commit -m "chore: bump version to $NEW_VERSION"
git tag "v$NEW_VERSION"
git push origin main
git push origin "v$NEW_VERSION"
build-binaries:
name: Build Binary (${{ matrix.platform }}-${{ matrix.arch }})
needs: version-bump
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x64
target: bun-linux-x64
- os: ubuntu-latest
platform: linux
arch: arm64
target: bun-linux-arm64
- os: macos-latest
platform: macos
arch: arm64
target: bun-darwin-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.version-bump.outputs.new_tag }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: |
npm install
cd cli
npm install
- name: Build CLI binary
run: |
cd cli
bun build src/cli.ts --outfile=../dist/facet-${{ matrix.platform }}-${{ matrix.arch }} --compile --target=${{ matrix.target }}
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: facet-${{ matrix.platform }}-${{ matrix.arch }}
path: dist/facet-${{ matrix.platform }}-${{ matrix.arch }}
retention-days: 1
create-release:
name: Create GitHub Release
needs: [version-bump, build-binaries]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: binaries
- name: Display structure of downloaded files
run: ls -R binaries
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ needs.version-bump.outputs.new_tag }} \
--repo ${{ github.repository }} \
--title "Release ${{ needs.version-bump.outputs.new_tag }}" \
--notes "Release ${{ needs.version-bump.outputs.new_version }}" \
binaries/facet-linux-x64/facet-linux-x64 \
binaries/facet-linux-arm64/facet-linux-arm64 \
binaries/facet-macos-arm64/facet-macos-arm64
publish-npm:
name: Publish to npm
needs: [version-bump, build-binaries]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.version-bump.outputs.new_tag }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: |
npm install
cd cli
npm install
- name: Build library
run: cd cli && npm run build:lib
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public