|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: release |
| 12 | + cancel-in-progress: false |
| 13 | + |
| 14 | +jobs: |
| 15 | + test: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 10 |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + node-version: ['24', '22', '20'] |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 24 | + |
| 25 | + - name: Setup Node |
| 26 | + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 |
| 27 | + with: |
| 28 | + node-version: ${{ matrix.node-version }} |
| 29 | + cache: 'npm' |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: npm ci |
| 33 | + |
| 34 | + - name: Run unit tests |
| 35 | + run: npm test |
| 36 | + |
| 37 | + build: |
| 38 | + needs: test |
| 39 | + strategy: |
| 40 | + matrix: |
| 41 | + include: |
| 42 | + - os: ubuntu-latest |
| 43 | + target: linux-x64 |
| 44 | + platform: linux |
| 45 | + arch: amd64 |
| 46 | + - os: ubuntu-latest |
| 47 | + target: linux-arm64 |
| 48 | + platform: linux |
| 49 | + arch: arm64 |
| 50 | + - os: macos-latest |
| 51 | + target: darwin-x64 |
| 52 | + platform: darwin |
| 53 | + arch: amd64 |
| 54 | + - os: macos-latest |
| 55 | + target: darwin-arm64 |
| 56 | + platform: darwin |
| 57 | + arch: arm64 |
| 58 | + - os: windows-latest |
| 59 | + target: windows-x64 |
| 60 | + platform: windows |
| 61 | + arch: amd64 |
| 62 | + |
| 63 | + runs-on: ${{ matrix.os }} |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 68 | + |
| 69 | + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 70 | + with: |
| 71 | + bun-version: 1 |
| 72 | + |
| 73 | + - name: Install dependencies |
| 74 | + run: bun install --frozen-lockfile |
| 75 | + |
| 76 | + - name: Build TypeScript |
| 77 | + run: bun run build |
| 78 | + |
| 79 | + - name: Build binary |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + BINARY_NAME="make-cli-${{ matrix.platform }}-${{ matrix.arch }}" |
| 83 | + if [ "${{ matrix.platform }}" = "windows" ]; then |
| 84 | + bun build dist/index.js --compile --target=bun-${{ matrix.target }} --outfile="${BINARY_NAME}.exe" |
| 85 | + else |
| 86 | + bun build dist/index.js --compile --target=bun-${{ matrix.target }} --outfile="${BINARY_NAME}" |
| 87 | + fi |
| 88 | +
|
| 89 | + - name: Create tar.gz archive |
| 90 | + shell: bash |
| 91 | + run: | |
| 92 | + BINARY_NAME="make-cli-${{ matrix.platform }}-${{ matrix.arch }}" |
| 93 | + if [ "${{ matrix.platform }}" = "windows" ]; then |
| 94 | + tar -czvf "${BINARY_NAME}.tar.gz" "${BINARY_NAME}.exe" |
| 95 | + else |
| 96 | + tar -czvf "${BINARY_NAME}.tar.gz" "${BINARY_NAME}" |
| 97 | + fi |
| 98 | +
|
| 99 | + - name: Upload artifact |
| 100 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 101 | + with: |
| 102 | + name: make-cli-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz |
| 103 | + path: make-cli-*.tar.gz |
| 104 | + retention-days: 7 |
| 105 | + |
| 106 | + build-deb: |
| 107 | + needs: build |
| 108 | + runs-on: ubuntu-latest |
| 109 | + strategy: |
| 110 | + matrix: |
| 111 | + arch: [amd64, arm64] |
| 112 | + |
| 113 | + steps: |
| 114 | + - name: Checkout |
| 115 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 116 | + |
| 117 | + - name: Download linux binary |
| 118 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 119 | + with: |
| 120 | + name: make-cli-linux-${{ matrix.arch }}.tar.gz |
| 121 | + path: . |
| 122 | + |
| 123 | + - name: Extract binary |
| 124 | + run: | |
| 125 | + mkdir -p bin |
| 126 | + tar -xzvf "make-cli-linux-${{ matrix.arch }}.tar.gz" -C bin/ |
| 127 | +
|
| 128 | + - name: Build Debian package |
| 129 | + run: | |
| 130 | + VERSION="${GITHUB_REF_NAME#v}" |
| 131 | + ./scripts/build-deb.sh "$VERSION" "${{ matrix.arch }}" |
| 132 | +
|
| 133 | + - name: Upload artifact |
| 134 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 135 | + with: |
| 136 | + name: make-cli-linux-${{ matrix.arch }}.deb |
| 137 | + path: deb/*.deb |
| 138 | + retention-days: 7 |
| 139 | + |
| 140 | + release: |
| 141 | + needs: [build, build-deb] |
| 142 | + runs-on: ubuntu-latest |
| 143 | + permissions: |
| 144 | + contents: write |
| 145 | + id-token: write |
| 146 | + |
| 147 | + steps: |
| 148 | + - name: Checkout |
| 149 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 150 | + |
| 151 | + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 152 | + with: |
| 153 | + bun-version: latest |
| 154 | + |
| 155 | + - name: Setup Node |
| 156 | + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 |
| 157 | + with: |
| 158 | + node-version: 24 |
| 159 | + registry-url: 'https://registry.npmjs.org' |
| 160 | + cache: 'npm' |
| 161 | + |
| 162 | + - name: Install dependencies |
| 163 | + run: bun install --frozen-lockfile |
| 164 | + |
| 165 | + - name: Build |
| 166 | + run: bun run build |
| 167 | + |
| 168 | + - name: Publish to npm |
| 169 | + run: npm publish --provenance --access public |
| 170 | + env: |
| 171 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 172 | + |
| 173 | + - name: Download all artifacts |
| 174 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 175 | + with: |
| 176 | + path: artifacts/ |
| 177 | + |
| 178 | + - name: Create release |
| 179 | + uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1 |
| 180 | + with: |
| 181 | + files: | |
| 182 | + artifacts/**/* |
| 183 | +
|
| 184 | + update-homebrew: |
| 185 | + needs: release |
| 186 | + runs-on: ubuntu-latest |
| 187 | + if: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY != '' }} |
| 188 | + |
| 189 | + steps: |
| 190 | + - name: Checkout |
| 191 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 192 | + |
| 193 | + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 194 | + with: |
| 195 | + bun-version: latest |
| 196 | + |
| 197 | + - name: Download artifacts |
| 198 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 199 | + with: |
| 200 | + path: artifacts/ |
| 201 | + |
| 202 | + - name: Generate Homebrew formula |
| 203 | + run: | |
| 204 | + VERSION="${GITHUB_REF_NAME#v}" |
| 205 | + VERSION="$VERSION" ARTIFACTS_DIR="artifacts" bun run scripts/update-homebrew.ts |
| 206 | +
|
| 207 | + - name: Push to homebrew-tap |
| 208 | + env: |
| 209 | + SSH_PRIVATE_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} |
| 210 | + run: | |
| 211 | + mkdir -p ~/.ssh |
| 212 | + echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key |
| 213 | + chmod 600 ~/.ssh/deploy_key |
| 214 | + ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 215 | +
|
| 216 | + git clone git@github.com:integromat/homebrew-tap.git tap --config core.sshCommand="ssh -i ~/.ssh/deploy_key" |
| 217 | + cp make-cli.rb tap/make-cli.rb |
| 218 | + cd tap |
| 219 | + git config user.name "make-cli-release-bot" |
| 220 | + git config user.email "make-cli-release-bot@make.com" |
| 221 | + git config core.sshCommand "ssh -i ~/.ssh/deploy_key" |
| 222 | + git add make-cli.rb |
| 223 | + git diff --staged --quiet || git commit -m "make-cli ${GITHUB_REF_NAME#v}" |
| 224 | + git push |
0 commit comments