Files
hypit/.github/workflows/npm-package.yml
2026-10-09 19:05:00 +08:00

88 lines
3.1 KiB
YAML

name: npm package execution
on:
workflow_dispatch:
workflow_call:
outputs:
version:
description: Version of the installed and executed tarball
value: ${{ jobs.build.outputs.version }}
permissions:
contents: read
concurrency:
group: npm-package-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Read the package version
id: version
run: node --input-type=module -e 'import { readFileSync, appendFileSync } from "node:fs"; const { version } = JSON.parse(readFileSync("package.json", "utf8")); appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}\n`);'
- name: Build the release candidate without publishing
run: npm run pack:release-candidate
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: npm-package
path: |
dist/release/*.tgz
dist/release/README.md
dist/release/release-plan.json
if-no-files-found: error
verify:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
timeout-minutes: 25
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Prepare the local media toolchain on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Prepare the local media toolchain on Windows
if: runner.os == 'Windows'
run: choco install ffmpeg --yes --no-progress
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: npm-package
path: dist/release
- name: Reuse npm downloads for the clean consumer installation
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ${{ runner.temp }}/hypit-npm-downloads
key: npm-consumer-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: npm-consumer-${{ runner.os }}-
- name: Install the complete candidate, render and export outside the checkout
env:
npm_config_cache: ${{ runner.temp }}/hypit-npm-downloads
run: npm run check:release-candidate