|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build executable for ${{ matrix.os }}-${{ matrix.arch }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: ubuntu-latest |
| 17 | + arch: x64 |
| 18 | + platform: linux-x64 |
| 19 | + target: bun-linux-x64 |
| 20 | + - os: macos-latest |
| 21 | + arch: x64 |
| 22 | + platform: darwin-x64 |
| 23 | + target: bun-darwin-x64 |
| 24 | + - os: macos-latest |
| 25 | + arch: arm64 |
| 26 | + platform: darwin-arm64 |
| 27 | + target: bun-darwin-arm64 |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 # Full history needed for git operations |
| 34 | + |
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: "22.22" |
| 39 | + |
| 40 | + - name: Setup pnpm |
| 41 | + uses: pnpm/action-setup@v4 |
| 42 | + with: |
| 43 | + version: 10.22.0 |
| 44 | + |
| 45 | + - name: Setup Bun |
| 46 | + uses: oven-sh/setup-bun@v2 |
| 47 | + with: |
| 48 | + bun-version: latest |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + run: pnpm install |
| 52 | + |
| 53 | + - name: Build executable |
| 54 | + run: | |
| 55 | + VERSION=$(node -p "require('./package.json').version") |
| 56 | + NODE_ENV=production bun build --compile --target=${{ matrix.target }} \ |
| 57 | + --define "CLI_VERSION='$VERSION'" \ |
| 58 | + src/index.ts --outfile=./bin/linear-release |
| 59 | +
|
| 60 | + - name: Code sign macOS executable |
| 61 | + if: matrix.os == 'macos-latest' |
| 62 | + run: | |
| 63 | + codesign --force --deep --sign - ./bin/linear-release || true |
| 64 | +
|
| 65 | + - name: Upload artifact |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: linear-release-${{ matrix.platform }} |
| 69 | + path: bin/linear-release* |
| 70 | + retention-days: 7 |
| 71 | + |
| 72 | + release: |
| 73 | + name: Create Release |
| 74 | + needs: build |
| 75 | + runs-on: ubuntu-latest |
| 76 | + if: startsWith(github.ref, 'refs/tags/') |
| 77 | + permissions: |
| 78 | + contents: write |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Checkout code |
| 82 | + uses: actions/checkout@v4 |
| 83 | + with: |
| 84 | + fetch-depth: 0 |
| 85 | + |
| 86 | + - name: Download all artifacts |
| 87 | + uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + path: ./artifacts |
| 90 | + |
| 91 | + - name: List artifacts |
| 92 | + run: | |
| 93 | + find ./artifacts -type f |
| 94 | + ls -la ./artifacts/ |
| 95 | +
|
| 96 | + - name: Extract tag name |
| 97 | + id: tag |
| 98 | + run: | |
| 99 | + TAG_NAME=${GITHUB_REF#refs/tags/} |
| 100 | + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
| 101 | + echo "Tag name: $TAG_NAME" |
| 102 | +
|
| 103 | + - name: Prepare release files |
| 104 | + run: | |
| 105 | + mkdir -p ./release-files |
| 106 | + # Copy each platform's executable with platform-specific name |
| 107 | + for dir in ./artifacts/linear-release-*/; do |
| 108 | + platform=$(basename "$dir" | sed 's/linear-release-//') |
| 109 | + if [ -f "$dir/linear-release" ]; then |
| 110 | + cp "$dir/linear-release" "./release-files/linear-release-${platform}" |
| 111 | + elif [ -f "$dir/linear-release.exe" ]; then |
| 112 | + cp "$dir/linear-release.exe" "./release-files/linear-release-${platform}.exe" |
| 113 | + fi |
| 114 | + done |
| 115 | + ls -la ./release-files/ |
| 116 | +
|
| 117 | + - name: Create Release |
| 118 | + uses: softprops/action-gh-release@v2 |
| 119 | + with: |
| 120 | + tag_name: ${{ steps.tag.outputs.tag_name }} |
| 121 | + name: Release ${{ steps.tag.outputs.tag_name }} |
| 122 | + files: | |
| 123 | + ./release-files/* |
| 124 | + generate_release_notes: true |
| 125 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 126 | + draft: false |
| 127 | + prerelease: false |
| 128 | + |
| 129 | + complete-release: |
| 130 | + name: Complete release |
| 131 | + needs: release |
| 132 | + uses: ./.github/workflows/run-linear-release.yml |
| 133 | + with: |
| 134 | + action: complete |
| 135 | + secrets: inherit |
0 commit comments