diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4af1c0fe..088ee3b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,8 @@ on: - main pull_request: jobs: - ci: - name: "Lint and Test" + lint_test: + name: Lint and Test runs-on: ubuntu-latest steps: # Install protoc for e2e:setup @@ -14,20 +14,9 @@ jobs: with: version: "23.4" - uses: bufbuild/buf-setup-action@v1.25.0 - - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - cache: "pnpm" - - run: pnpm install --frozen-lockfile - - run: (cd packages/twirpscript && pnpm package:build) - # run again to link bin that is now available after package:build - - run: pnpm install --frozen-lockfile - - run: pnpm lint - - run: pnpm test:ci && pnpm codecov --token=$CODECOV_TOKEN - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - uses: tatethurston/github-actions/test@main + with: + codecov_token: ${{ secrets.CODECOV_TOKEN }} - name: Check for uncommited changes to generated files run: | pnpm regen @@ -40,3 +29,34 @@ jobs: echo "Failing build." exit 1 fi + build_package: + name: Build Package + runs-on: ubuntu-latest + outputs: + package-name: package-${{ github.event.pull_request.number }} + steps: + - uses: tatethurston/github-actions/build@main + - name: NPM Pack + run: | + cd packages/twirpscript + pnpm pack + - uses: actions/upload-artifact@v4 + with: + name: package-${{ github.event.pull_request.number }} + path: packages/twirpscript/*.tgz + if-no-files-found: error + retention-days: 1 + overwrite: true + check_windows: + name: Windows CI Check + runs-on: windows-latest + needs: build_package + steps: + - uses: actions/download-artifact@v4 + with: + name: ${{ needs.build_package.outputs.package-name }} + - uses: actions/setup-node@v3 + - name: Bin Check + run: | + npm install *.tgz + npm twirpscript diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7da7da70..c843771d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,20 +1,13 @@ name: Publish NPM Package on: release: - types: [created] + types: [published] + workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - - uses: actions/setup-node@v3 + - uses: tatethurston/github-actions/publish@main with: - node-version-file: ".nvmrc" - cache: "pnpm" - registry-url: "https://registry.npmjs.org" - - run: pnpm install --frozen-lockfile - - run: cp README.md LICENSE CHANGELOG.md packages/twirpscript - - run: cd packages/twirpscript && pnpm package:build && npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + package_directory: packages/twirpscript + npm_token: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 298c8fc5..c09c9b63 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ }, "type": "module", "scripts": { + "build": "(pnpm package:copy:files && cd packages/twirpscript && pnpm package:build)", + "package:copy:files": "cp ./LICENSE ./README.md packages/twirpscript", "e2e:regen": "pnpm --filter './e2e/*' exec twirpscript", "examples:buf:regen": "(cd examples/buf && buf generate)", "examples:regen": "pnpm examples:buf:regen && for f in examples/*; do if [ $f != examples/buf ]; then (cd $f; pnpm twirpscript); fi; done", @@ -17,7 +19,8 @@ "prepare": "husky install", "regen": "pnpm examples:regen && pnpm e2e:regen", "test": "jest", - "test:ci": "jest examples/* packages/* --coverage", + "//": "pnpm install again to link bin that is now available after package:build", + "test:ci": "pnpm install --frozen-lockfile && jest examples/* packages/* --coverage", "test:integration": "pnpm run test-protos && pnpm run test-clientcompat", "test-clientcompat": "(cd ./src/integration-tests/clientcompat && pnpm run build && npx twirpscript)", "test-protos": "(cd src/integration-tests/protos && pnpm run build && pnpm run typecheck:protos)",