Merge pull request #12 from azwebmaster/changeset-release/main #20
This file contains hidden or 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: Main | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| ci: | |
| name: CI | |
| uses: ./.github/workflows/shared-ci.yml | |
| publish: | |
| name: Publish | |
| runs-on: macos-latest | |
| needs: ci | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Cache Bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.bun/install/cache | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Install Dependencies | |
| run: bun install | |
| - name: Build | |
| run: bun run build | |
| - name: Setup Node.js for NPM | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Create Release Pull Request or Publish to NPM | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| publish: bun run release | |
| version: bun run version | |
| commit: "chore: release package" | |
| title: "chore: release package" | |
| createGithubReleases: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
| - name: Get version and changelog | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
| echo "TAG=v$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
| - name: Build executables | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| # macOS (Intel) | |
| bun build src/cli.ts --compile --outfile dependency-optimizer-macos-x64 | |
| # macOS (Apple Silicon) | |
| bun build src/cli.ts --compile --outfile dependency-optimizer-macos-arm64 --target=bun-darwin-arm64 | |
| # Linux | |
| bun build src/cli.ts --compile --outfile dependency-optimizer-linux-x64 --target=bun-linux-x64 | |
| # Windows | |
| bun build src/cli.ts --compile --outfile dependency-optimizer-windows-x64.exe --target=bun-windows-x64 | |
| - name: Create tgz archives | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| tar -czf dependency-optimizer-macos-x64.tgz dependency-optimizer-macos-x64 | |
| tar -czf dependency-optimizer-macos-arm64.tgz dependency-optimizer-macos-arm64 | |
| tar -czf dependency-optimizer-linux-x64.tgz dependency-optimizer-linux-x64 | |
| tar -czf dependency-optimizer-windows-x64.tgz dependency-optimizer-windows-x64.exe | |
| - name: Upload executables to release | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| gh release upload ${{ env.TAG }} \ | |
| dependency-optimizer-macos-x64.tgz \ | |
| dependency-optimizer-macos-arm64.tgz \ | |
| dependency-optimizer-linux-x64.tgz \ | |
| dependency-optimizer-windows-x64.tgz \ | |
| --clobber | |
| env: | |
| TAG: ${{ env.TAG }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |