|
| 1 | +name: Release Plugin Assert |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "plugin-assert-v*.*.*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + dry-run: |
| 10 | + description: "Dry run (don't actually publish)" |
| 11 | + required: false |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + name: Build and Publish Plugin Assert |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + id-token: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Extract version from tag |
| 28 | + id: version |
| 29 | + run: | |
| 30 | + if [[ "${{ github.event_name }}" == "push" ]]; then |
| 31 | + # Extract version from tag (plugin-assert-v1.2.3 -> 1.2.3) |
| 32 | + VERSION="${GITHUB_REF#refs/tags/plugin-assert-v}" |
| 33 | + else |
| 34 | + # For manual trigger, read from package.json |
| 35 | + VERSION=$(jq -r .version packages/plugins/assert/package.json) |
| 36 | + fi |
| 37 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 38 | + echo "Extracted version: $VERSION" |
| 39 | +
|
| 40 | + - name: Verify version matches package.json |
| 41 | + run: | |
| 42 | + PKG_VERSION=$(jq -r .version packages/plugins/assert/package.json) |
| 43 | + TAG_VERSION="${{ steps.version.outputs.version }}" |
| 44 | + if [[ "$PKG_VERSION" != "$TAG_VERSION" ]]; then |
| 45 | + echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)" |
| 46 | + echo "The tag must match the committed version. Ensure you've merged the Version Packages PR first." |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | + echo "Version verified: $PKG_VERSION" |
| 50 | +
|
| 51 | + - name: Setup Bun |
| 52 | + uses: oven-sh/setup-bun@v2 |
| 53 | + with: |
| 54 | + bun-version-file: package.json |
| 55 | + |
| 56 | + - name: Setup Node.js |
| 57 | + uses: actions/setup-node@v4 |
| 58 | + with: |
| 59 | + node-version: "20" |
| 60 | + registry-url: "https://registry.npmjs.org" |
| 61 | + |
| 62 | + - name: Install dependencies |
| 63 | + run: bun install --frozen-lockfile |
| 64 | + |
| 65 | + - name: Verify publish manifest |
| 66 | + run: bun run script/verify-publish-manifest.ts packages/plugins/assert/package.json |
| 67 | + |
| 68 | + - name: Build core (workspace dependency) |
| 69 | + run: bun run build |
| 70 | + working-directory: packages/core |
| 71 | + |
| 72 | + - name: Build |
| 73 | + run: bun run build |
| 74 | + working-directory: packages/plugins/assert |
| 75 | + |
| 76 | + - name: Check types |
| 77 | + run: bun run check-types |
| 78 | + working-directory: packages/plugins/assert |
| 79 | + |
| 80 | + - name: Run tests |
| 81 | + run: bun run test |
| 82 | + working-directory: packages/plugins/assert |
| 83 | + |
| 84 | + - name: Publish to npm |
| 85 | + if: ${{ github.event_name == 'push' || !inputs.dry-run }} |
| 86 | + run: npm publish --access public |
| 87 | + working-directory: packages/plugins/assert |
| 88 | + env: |
| 89 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 90 | + |
| 91 | + - name: Dry run publish |
| 92 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run }} |
| 93 | + run: | |
| 94 | + npm pack |
| 95 | + echo "[dry-run] Would publish @t-req/plugin-assert@${{ steps.version.outputs.version }}" |
| 96 | + working-directory: packages/plugins/assert |
0 commit comments