ci(videos): fix the lint errors that fail the release workflow #108
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release | |
| # On every push to main: publish the collector to npm as @usagefleet/cli and tag | |
| # the commit. That package is the only install channel — `npm i -g` on any OS | |
| # with Node 20+, and installed collectors self-update from the same registry. | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| # The whole npm credential: this job authenticates to the registry as "the | |
| # release.yml workflow of this repo" over OIDC (npm trusted publishing), so | |
| # there is no publish token to leak, and the registry attests that the tarball | |
| # was built here, from this commit. | |
| id-token: write | |
| concurrency: | |
| group: release | |
| cancel-in-progress: true | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| # Node for the publish itself, not the version users get: oxlint strips | |
| # types off oxlint.config.ts natively (needs >=22.18) and trusted | |
| # publishing needs >=22.14, while the package itself still supports 20. | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| # Trusted publishing landed in npm 11.5.1; the runner image's bundled npm | |
| # is whatever Node 24 shipped with, so don't leave it to chance. | |
| - name: Upgrade npm | |
| run: npm install -g npm@latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| # This package self-installs onto user machines, so nothing ships until | |
| # the linter and the suite agree it should. The type checker gates it too, | |
| # one step later: apps/cli's prepublishOnly runs `tsc`, so a type error | |
| # fails the publish itself. | |
| - name: Lint | |
| run: bun run lint | |
| - name: Test | |
| run: bun run test | |
| # major.minor come from the manifest, the run number is the patch: every | |
| # push to main gets a unique, increasing x.x.x. | |
| - name: Compute version | |
| id: meta | |
| run: | | |
| BASE=$(jq -r .version apps/cli/package.json | cut -d. -f1,2) | |
| echo "version=${BASE}.${{ github.run_number }}" >> "$GITHUB_OUTPUT" | |
| echo "tag=v${BASE}.${{ github.run_number }}" >> "$GITHUB_OUTPUT" | |
| # Two places need the number: the manifest npm publishes under, and the | |
| # constant the CLI compares against the registry to decide it is stale. | |
| # Local builds keep the committed "dev" value, which disables self-update. | |
| # `npm pkg set`, not `npm version`: the latter reconciles node_modules | |
| # against a lockfile and would undo bun's install (dropping the | |
| # platform-native tsc binary the build needs). | |
| - name: Set version | |
| working-directory: apps/cli | |
| env: | |
| VERSION: ${{ steps.meta.outputs.version }} | |
| run: | | |
| npm pkg set version="$VERSION" | |
| { | |
| echo '// Generated by .github/workflows/release.yml.' | |
| echo "export const RELEASE_VERSION: string = \"$VERSION\";" | |
| } > src/release.ts | |
| # No token: the OIDC identity above is the credential. Requires a trusted | |
| # publisher on npmjs.com pinned to this repo + workflow filename. | |
| # --provenance needs this repo to stay public; npm rejects the bundle | |
| # (422) if it ever flips back to private. | |
| - name: Publish to npm | |
| working-directory: apps/cli | |
| run: npm publish --provenance --access public | |
| # The exact bytes that went to the registry, attached to the release so a | |
| # version can be inspected or installed offline (`npm i -g ./<file>.tgz`) | |
| # without going through npm. dist/ is already built by prepublishOnly. | |
| - name: Pack the published tarball | |
| working-directory: apps/cli | |
| run: npm pack | |
| - name: Tag the release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.meta.outputs.tag }} | |
| name: usagefleet ${{ steps.meta.outputs.tag }} | |
| body: | | |
| On npm as `@usagefleet/cli@${{ steps.meta.outputs.version }}`: | |
| https://www.npmjs.com/package/@usagefleet/cli | |
| ```bash | |
| npm i -g @usagefleet/cli | |
| # autostart: launchd / systemd / Task Scheduler | |
| usagefleet install --token uf_xxx | |
| ``` | |
| Already installed? It updates itself within six hours, or run | |
| `usagefleet update`. | |
| files: apps/cli/usagefleet-cli-${{ steps.meta.outputs.version }}.tgz | |
| make_latest: true | |
| generate_release_notes: true | |
| # The bump above only existed inside the runner. Commit the manifest back | |
| # so the repo states the version that is actually on npm. Only | |
| # package.json: src/release.ts stays "dev" in git on purpose. A push made | |
| # with GITHUB_TOKEN does not trigger workflows, so this cannot loop. | |
| - name: Commit the version bump | |
| env: | |
| VERSION: ${{ steps.meta.outputs.version }} | |
| run: | | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| git commit -m "chore(cli): v$VERSION" -- package.json | |
| git push origin HEAD:main | |
| working-directory: apps/cli |