Skip to content

publish v1.1.0-alpha (release) #160

publish v1.1.0-alpha (release)

publish v1.1.0-alpha (release) #160

Workflow file for this run

name: publish
on:
workflow_dispatch:
inputs:
version:
description: version
required: true
type: string
default: 1.1.0-alpha
dist_tag:
description: npm dist-tag
required: true
type: choice
default: "<auto>"
options:
- "<auto>"
- next
- beta
- rc
- latest
force_publish:
description: force publish all packages
required: false
type: boolean
default: false
create_release:
description: create release
required: true
type: boolean
default: true
prerelease:
description: prerelease
required: true
type: boolean
default: true
draft:
description: draft
required: true
type: boolean
default: true
run-name: "publish v${{ inputs.version }} (${{ inputs.draft && 'draft' || 'release' }})"
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.validate.outputs.version }}
dist_tag: ${{ steps.validate.outputs.dist_tag }}
prerelease: ${{ steps.validate.outputs.prerelease }}
changed_files: ${{ steps.detect_changes.outputs.changed_files }}
changed_packages: ${{ steps.detect_changes.outputs.changed_packages }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: validate
id: validate
env:
VERSION_SPEC: ${{ inputs.version }}
DIST_TAG: ${{ inputs.dist_tag }}
PRERELEASE: ${{ inputs.prerelease }}
run: |
node scripts/validate-version.js
- name: yarn install
run: |
yarn install --immutable
- name: lerna version
run: lerna version ${{ steps.validate.outputs.version }} --no-git-tag-version --no-push --yes $([ ${{ inputs.force_publish }} == true ] && echo "--force-publish" )
- name: generate native packages
run: |
yarn run generate-native-packages
- name: upload version artifacts
uses: actions/upload-artifact@v3
with:
name: version-artifacts
path: |
internal/*/package*.json
packages/*/package*.json
native/*/package*.json
package.json
lerna.json
yarn.lock
- name: detect changes
id: detect_changes
run: |
# collect the package files that have changed since the last version bump, producing a JSON array of file names.
echo "changed_files=$(
git status --porcelain -- package.json lerna.json yarn.lock internal/*/package*.json packages/*/package*.json native/*/package*.json |
cut -c 4- |
node -e 'process.stdout.write(JSON.stringify(fs.readFileSync(0, "utf8").split(/\n/g).filter(Boolean)))'
)" >> $GITHUB_OUTPUT;
# collect the package.json files that have changed since the last version bump, producing a JSON object like '{ [path]: true }'
echo "changed_packages=$(
git status --porcelain -- internal/*/package.json packages/*/package.json native/*/package.json |
cut -c 4- |
node -e 'process.stdout.write(JSON.stringify(fs.readFileSync(0, "utf8").split(/\n/g).filter(Boolean).reduce((obj, path) => ({ ...obj, [path]: true }), {})))'
)" >> $GITHUB_OUTPUT;
native:
strategy:
matrix:
os:
- name: windows
target: windows-2019
- name: linux
target: ubuntu-latest
- name: macos
target: macos-latest
runtime:
- label: node v16
runtime: node
node_version: 16
- label: node v18
runtime: node
node_version: 18
- label: electron
runtime: electron
node_version: 18
name: "${{ matrix.os.name }} (${{ matrix.runtime.label }})"
runs-on: ${{ matrix.os.target }}
needs:
- version
# TODO: Do not build if binary packages not included in changed packages
# TODO: Test binaries
steps:
- uses: actions/checkout@v3
- name: use node ${{ matrix.runtime.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.runtime.node_version }}
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: install
run: |
yarn install --immutable
- name: version
uses: actions/download-artifact@v3
with:
name: version-artifacts
path: ${{ github.workspace }}
- name: build ${{ matrix.runtime.runtime }} binaries
run: yarn run build-${{ matrix.runtime.runtime }}-${{ matrix.os.name }}
- name: upload build artifacts
uses: actions/upload-artifact@v3
with:
name: native-artifacts
path: |
native/*/dist/**
docs:
runs-on: windows-2019
needs:
- version
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: install
run: |
yarn install --immutable
- name: version
uses: actions/download-artifact@v3
with:
name: version-artifacts
path: ${{ github.workspace }}
- name: build
run: |
yarn run clean
yarn run prebuild
yarn run build
- name: docs
run: yarn run docs
- name: upload docs artifacts
uses: actions/upload-artifact@v3
with:
name: docs-artifacts
path: |
docs/**
package:
runs-on: ubuntu-latest
needs:
- version
- native
- docs
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: install
run: |
yarn install --immutable
- name: version
uses: actions/download-artifact@v3
with:
name: version-artifacts
path: ${{ github.workspace }}
- name: generate native packages
run: |
yarn run generate-native-packages
- name: build
run: |
yarn run clean
yarn run prebuild
yarn run build
- name: download native artifacts
uses: actions/download-artifact@v3
with:
name: native-artifacts
path: ${{ github.workspace }}/native
- name: test
run: |
yarn run test --selectProjects "collections-hash ts-worker"
yarn run test --selectProjects "async-autoresetevent async-barrier async-conditionvariable async-countdown async-deferred async-manualresetevent async-mutex async-queue async-readerwriterlock async-semaphore async-stack canceltoken"
yarn run test --selectProjects "collection-core collection-core-shim collections-hashmap collections-hashset collections-multimap collections-sortedmap collections-sortedset"
yarn run test --selectProjects "async-iter-fn async-iter-fromsync async-iter-query iter-fn iter-lookup iter-query"
yarn run test --selectProjects "threading-autoresetevent threading-conditionvariable threading-manualresetevent threading-mutex threading-sleep"
yarn run test --selectProjects "decorators disposable equatable equatable-shim fn fn-partial indexed-object lazy ref reflect-metadata-compat struct-type"
- name: test (esm output)
run: |
yarn run test-esm --selectProjects "async-autoresetevent async-barrier async-conditionvariable async-countdown async-deferred async-manualresetevent async-mutex async-queue async-readerwriterlock async-semaphore async-stack canceltoken"
yarn run test-esm --selectProjects "collections-hash collection-core collection-core-shim collections-hashmap collections-hashset collections-multimap collections-sortedmap collections-sortedset"
yarn run test-esm --selectProjects "async-iter-fn async-iter-fromsync async-iter-query iter-fn iter-lookup iter-query"
yarn run test-esm --selectProjects "threading-autoresetevent threading-conditionvariable threading-manualresetevent threading-mutex threading-sleep"
yarn run test-esm --selectProjects "decorators disposable equatable equatable-shim fn fn-partial indexed-object lazy ref reflect-metadata-compat struct-type"
- name: verify
run: |
yarn run verify
yarn run prepack
- name: download docs artifacts
uses: actions/download-artifact@v3
with:
name: docs-artifacts
path: docs
- name: commit changes
if: ${{ inputs.create_release || ! inputs.draft }}
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git add -- ${{ join(fromJson(needs.version.outputs.changed_files), ' ') }}
git add -- docs
git commit -m "v${{ needs.version.outputs.version }}"
- name: tag and push commit
if: ${{ inputs.create_release }}
run: |
git tag -f "v${{ needs.version.outputs.version }}" -m "v${{ needs.version.outputs.version }}"
git push --follow-tags --no-verify --atomic origin ${{ github.ref_name }}
echo "release_sha=$( git show -s --format=%H )" >> $GITHUB_ENV
- name: create release
if: ${{ inputs.create_release }}
uses: ncipollo/release-action@v1
with:
tag: "v${{ needs.version.outputs.version }}"
commit: ${{ env.release_sha || github.sha }}
draft: ${{ inputs.draft }}
prerelease: ${{ needs.version.outputs.prerelease != 'false' }}
allowUpdates: true
- name: publish
if: ${{ ! inputs.draft }}
run: |
lerna publish from-git --yes --no-verify-access --no-git-reset --dist-tag ${{ needs.version.outputs.dist_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}