|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build ${{ matrix.output }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - target: bun-darwin-x64 |
| 17 | + output: commita-darwin-amd64 |
| 18 | + - target: bun-darwin-arm64 |
| 19 | + output: commita-darwin-arm64 |
| 20 | + - target: bun-linux-x64 |
| 21 | + output: commita-linux-amd64 |
| 22 | + - target: bun-windows-x64 |
| 23 | + output: commita-windows-amd64.exe |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - uses: oven-sh/setup-bun@v2 |
| 29 | + |
| 30 | + - run: bun install |
| 31 | + |
| 32 | + - name: Build |
| 33 | + run: bun build index.ts --compile --target=${{ matrix.target }} --outfile ${{ matrix.output }} |
| 34 | + |
| 35 | + - uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: ${{ matrix.output }} |
| 38 | + path: ${{ matrix.output }} |
| 39 | + if-no-files-found: error |
| 40 | + |
| 41 | + version: |
| 42 | + name: Create version tag |
| 43 | + needs: build |
| 44 | + if: github.ref == 'refs/heads/main' |
| 45 | + runs-on: ubuntu-latest |
| 46 | + permissions: |
| 47 | + contents: write |
| 48 | + outputs: |
| 49 | + new_tag: ${{ steps.tag.outputs.new_tag }} |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + with: |
| 53 | + fetch-depth: 0 |
| 54 | + |
| 55 | + - id: tag |
| 56 | + uses: mathieudutour/github-tag-action@v6.2 |
| 57 | + with: |
| 58 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + tag_prefix: v |
| 60 | + default_bump: patch |
| 61 | + release_branches: main |
| 62 | + |
| 63 | + release: |
| 64 | + name: Release |
| 65 | + needs: [build, version] |
| 66 | + if: github.ref == 'refs/heads/main' && needs.version.outputs.new_tag != '' |
| 67 | + runs-on: ubuntu-latest |
| 68 | + permissions: |
| 69 | + contents: write |
| 70 | + steps: |
| 71 | + - uses: actions/download-artifact@v4 |
| 72 | + with: |
| 73 | + merge-multiple: true |
| 74 | + |
| 75 | + - uses: softprops/action-gh-release@v2 |
| 76 | + with: |
| 77 | + tag_name: ${{ needs.version.outputs.new_tag }} |
| 78 | + generate_release_notes: true |
| 79 | + files: | |
| 80 | + commita-darwin-amd64 |
| 81 | + commita-darwin-arm64 |
| 82 | + commita-linux-amd64 |
| 83 | + commita-windows-amd64.exe |
0 commit comments