Publish to npm #29
This file contains 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: build | |
on: [push, pull_request] | |
jobs: | |
test: | |
strategy: | |
matrix: | |
os: [macos-12, ubuntu-22.04, windows-2022] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
permissions: | |
checks: write | |
pull-requests: write | |
env: | |
OS: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.x | |
- run: >- | |
deno test | |
--doc | |
--coverage=.cov | |
--junit-path=.test-report.xml | |
- uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: runner.os == 'Linux' && always() | |
with: | |
files: .test-report.xml | |
- uses: EnricoMi/publish-unit-test-result-action/composite@v2 | |
if: runner.os != 'Linux' && always() | |
with: | |
files: .test-report.xml | |
- run: deno coverage --lcov .cov > .cov.lcov | |
- uses: codecov/codecov-action@v2 | |
with: | |
files: .cov.lcov | |
env_vars: OS | |
lint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.x | |
- run: deno lint | |
- run: deno fmt --check --ignore=.vscode/ | |
release: | |
if: github.event_name == 'push' | |
needs: [test, lint] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.x | |
- id: determine-version | |
run: deno run -A scripts/determine-version.ts | |
- if: github.ref_type == 'tag' | |
run: '[[ "$VERSION" = "$GITHUB_REF_NAME" ]]' | |
env: | |
VERSION: ${{ steps.determine-version.outputs.version }} | |
- run: | | |
set -e | |
deno run -A dnt.ts "$VERSION" | |
pushd npm/ | |
npm pack --dry-run | |
popd | |
env: | |
VERSION: ${{ steps.determine-version.outputs.version }} | |
- run: deno install -Af --unstable https://x.nest.land/[email protected]/eggs.ts | |
- run: "eggs link '${{ secrets.NEST_API_KEY }}'" | |
- if: github.ref_type == 'tag' | |
uses: mikefarah/yq@master | |
with: | |
cmd: >- | |
yq -i | |
' strenv(GITHUB_REF_NAME) as $version | |
| .version = $version | |
| .unstable = false' | |
egg.yaml | |
- if: github.ref_type != 'tag' | |
uses: mikefarah/yq@master | |
with: | |
cmd: >- | |
yq -i | |
' strenv(VERSION) as $version | |
| .version = $version | |
| .unstable = true' | |
egg.yaml | |
env: | |
VERSION: ${{ steps.determine-version.outputs.version }} | |
- run: | | |
# Try up to 3 times as `eggs publish` frequently fails due to unknown | |
# reason (I guess it's a bug on the server side): | |
for _ in 1 2 3; do | |
eggs publish --debug --yes --no-check || continue | |
done | |
- if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: eggs-debug.log | |
path: ${{ github.workspace }}/eggs-debug.log | |
- run: | | |
set -e | |
cd npm/ | |
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then | |
npm publish | |
else | |
npm publish --tag dev | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} |