|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + binaries: |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + include: |
| 14 | + - target: bun-linux-x64 |
| 15 | + name: linux-x64 |
| 16 | + archive: tar.gz |
| 17 | + - target: bun-linux-arm64 |
| 18 | + name: linux-arm64 |
| 19 | + archive: tar.gz |
| 20 | + - target: bun-darwin-x64 |
| 21 | + name: darwin-x64 |
| 22 | + archive: tar.gz |
| 23 | + - target: bun-darwin-arm64 |
| 24 | + name: darwin-arm64 |
| 25 | + archive: tar.gz |
| 26 | + - target: bun-windows-x64 |
| 27 | + name: windows-x64 |
| 28 | + archive: zip |
| 29 | + |
| 30 | + runs-on: ubuntu-latest |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Bun |
| 36 | + uses: oven-sh/setup-bun@v2 |
| 37 | + with: |
| 38 | + bun-version: latest |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + run: bun install |
| 42 | + |
| 43 | + - name: Set version from tag |
| 44 | + id: version |
| 45 | + run: | |
| 46 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 47 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Compile binary |
| 50 | + run: | |
| 51 | + mkdir -p dist-binaries |
| 52 | + BINARY_NAME="workout" |
| 53 | + if [[ "${{ matrix.name }}" == windows-* ]]; then |
| 54 | + BINARY_NAME="workout.exe" |
| 55 | + fi |
| 56 | + bun build ./src/index.ts --compile --target=${{ matrix.target }} --minify --outfile=dist-binaries/$BINARY_NAME |
| 57 | +
|
| 58 | + - name: Create archive |
| 59 | + run: | |
| 60 | + VERSION=${{ steps.version.outputs.version }} |
| 61 | + ARCHIVE_DIR="workout-${VERSION}-${{ matrix.name }}" |
| 62 | + mkdir -p "$ARCHIVE_DIR" |
| 63 | +
|
| 64 | + if [[ "${{ matrix.name }}" == windows-* ]]; then |
| 65 | + cp dist-binaries/workout.exe "$ARCHIVE_DIR/" |
| 66 | + else |
| 67 | + cp dist-binaries/workout "$ARCHIVE_DIR/" |
| 68 | + fi |
| 69 | +
|
| 70 | + if [[ "${{ matrix.archive }}" == "tar.gz" ]]; then |
| 71 | + tar -czvf "dist-binaries/workout-${VERSION}-${{ matrix.name }}.tar.gz" "$ARCHIVE_DIR" |
| 72 | + else |
| 73 | + zip -r "dist-binaries/workout-${VERSION}-${{ matrix.name }}.zip" "$ARCHIVE_DIR" |
| 74 | + fi |
| 75 | +
|
| 76 | + - name: Upload artifact |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + with: |
| 79 | + name: binary-${{ matrix.name }} |
| 80 | + path: dist-binaries/workout-*.* |
| 81 | + retention-days: 1 |
| 82 | + |
| 83 | + release: |
| 84 | + needs: binaries |
| 85 | + runs-on: ubuntu-latest |
| 86 | + permissions: |
| 87 | + contents: write |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Download all artifacts |
| 91 | + uses: actions/download-artifact@v4 |
| 92 | + with: |
| 93 | + path: dist-binaries |
| 94 | + pattern: binary-* |
| 95 | + merge-multiple: true |
| 96 | + |
| 97 | + - name: Generate checksums |
| 98 | + run: | |
| 99 | + cd dist-binaries |
| 100 | + sha256sum workout-*.tar.gz workout-*.zip > checksums.txt |
| 101 | + cat checksums.txt |
| 102 | +
|
| 103 | + - name: Upload to GitHub Release |
| 104 | + uses: softprops/action-gh-release@v2 |
| 105 | + with: |
| 106 | + files: | |
| 107 | + dist-binaries/*.tar.gz |
| 108 | + dist-binaries/*.zip |
| 109 | + dist-binaries/checksums.txt |
| 110 | + fail_on_unmatched_files: true |
| 111 | + generate_release_notes: true |
0 commit comments