webamp/.github/workflows/ci.yml
2025-12-17 16:51:54 -08:00

125 lines
4.6 KiB
YAML

name: CI
on:
push:
pull_request:
jobs:
# Main CI job - using Turborepo for dependency management
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9.12.0
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "pnpm"
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build all packages
run: |
npx turbo build build-library
env:
NODE_ENV: production
- name: Lint and type-check
run: |
npx turbo lint type-check
- name: Validate Grats generated files are up-to-date
run: ./scripts/validate-grats.sh
- name: Run tests
run: |
npx turbo test -- --maxWorkers=2
env:
NODE_ENV: test
- name: Cache build artifacts for release
uses: actions/cache@v4
with:
path: |
packages/ani-cursor/dist
packages/winamp-eqf/built
packages/webamp/built
key: release-artifacts-${{ github.sha }}
# Release job - publish packages to NPM
release:
name: Publish packages to NPM
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'captbaritone/webamp'
needs: [ci]
permissions:
contents: read
id-token: write # Required for OIDC trusted publishing
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9.12.0
- uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org/
cache: "pnpm"
- name: Update npm to latest version
run: npm install -g npm@latest
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Restore build artifacts
uses: actions/cache@v4
with:
path: |
packages/ani-cursor/dist
packages/winamp-eqf/built
packages/webamp/built
key: release-artifacts-${{ github.sha }}
fail-on-cache-miss: true
- name: Set version for all packages
if: github.ref == 'refs/heads/master'
run: |
echo "Setting version to 0.0.0-next-${RELEASE_COMMIT_SHA::7}"
cd packages/webamp && npm version 0.0.0-next-${RELEASE_COMMIT_SHA::7} --no-git-tag-version
cd ../ani-cursor && npm version 0.0.0-next-${RELEASE_COMMIT_SHA::7} --no-git-tag-version
cd ../winamp-eqf && npm version 0.0.0-next-${RELEASE_COMMIT_SHA::7} --no-git-tag-version
env:
RELEASE_COMMIT_SHA: ${{ github.sha }}
- name: Set version for tagged release
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "Setting version to $VERSION for tagged release"
cd packages/webamp && npm version $VERSION --no-git-tag-version
cd ../ani-cursor && npm version $VERSION --no-git-tag-version
cd ../winamp-eqf && npm version $VERSION --no-git-tag-version
# TODO: Update version number in webampLazy.tsx if needed
- name: Publish ani-cursor to npm
working-directory: ./packages/ani-cursor
if: github.ref == 'refs/heads/master' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))
run: |
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
npm publish --tag=next --ignore-scripts --provenance
else
npm publish --ignore-scripts --provenance
fi
- name: Publish winamp-eqf to npm
working-directory: ./packages/winamp-eqf
if: github.ref == 'refs/heads/master' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))
run: |
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
npm publish --tag=next --ignore-scripts --provenance
else
npm publish --ignore-scripts --provenance
fi
- name: Publish webamp to npm
working-directory: ./packages/webamp
if: github.ref == 'refs/heads/master' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))
# Use pre-built artifacts instead of rebuilding
run: |
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
npm publish --tag=next --ignore-scripts --provenance
else
npm publish --ignore-scripts --provenance
fi