Repository navigation
release #2
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: release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to build and upload (e.g. v1.2.3)" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| meta: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.meta.outputs.tag }} | |
| steps: | |
| - id: meta | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| verify: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| needs: meta | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ needs.meta.outputs.tag }} | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: "1.3.8" | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Run CI checks | |
| run: make test-all | |
| create_release: | |
| runs-on: ubuntu-latest | |
| needs: [meta, verify] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ needs.meta.outputs.tag }} | |
| - name: Create GitHub Release (if missing) | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG='${{ needs.meta.outputs.tag }}' | |
| if gh release view "$TAG" >/dev/null 2>&1; then | |
| echo "Release already exists: $TAG" | |
| exit 0 | |
| fi | |
| gh release create "$TAG" --generate-notes | |
| build_upload: | |
| needs: [meta, create_release] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| bun_target: bun-linux-x64 | |
| platform: linux-x64 | |
| exe: roboppi | |
| - os: ubuntu-latest | |
| bun_target: bun-linux-arm64 | |
| platform: linux-arm64 | |
| exe: roboppi | |
| - os: macos-latest | |
| bun_target: bun-darwin-arm64 | |
| platform: macos-arm64 | |
| exe: roboppi | |
| - os: macos-latest | |
| bun_target: bun-darwin-x64 | |
| platform: macos-x64 | |
| exe: roboppi | |
| - os: windows-latest | |
| bun_target: bun-windows-x64 | |
| platform: windows-x64 | |
| exe: roboppi.exe | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ needs.meta.outputs.tag }} | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: "1.3.8" | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build standalone binary | |
| shell: bash | |
| run: | | |
| rm -rf dist release stage | |
| mkdir -p dist | |
| bun build --compile --target=${{ matrix.bun_target }} --outfile "dist/${{ matrix.exe }}" src/cli.ts | |
| - name: Package (tar.gz) | |
| shell: bash | |
| run: | | |
| TAG='${{ needs.meta.outputs.tag }}' | |
| ASSET="roboppi-${TAG}-${{ matrix.platform }}" | |
| mkdir -p stage release | |
| cp "dist/${{ matrix.exe }}" stage/ | |
| cp README.md stage/ | |
| if [[ -f README.ja.md ]]; then cp README.ja.md stage/; fi | |
| tar -czf "release/${ASSET}.tar.gz" -C stage . | |
| ASSET="$ASSET" python - <<'PY' | |
| import os | |
| import hashlib | |
| from pathlib import Path | |
| asset = os.environ["ASSET"] | |
| p = Path("release") / f"{asset}.tar.gz" | |
| h = hashlib.sha256(p.read_bytes()).hexdigest() | |
| (p.parent / (p.name + ".sha256")).write_text(f"{h} {p.name}\n", encoding="utf-8") | |
| PY | |
| - name: Upload assets to GitHub Release | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG='${{ needs.meta.outputs.tag }}' | |
| ASSET="roboppi-${TAG}-${{ matrix.platform }}" | |
| gh release upload "$TAG" \ | |
| "release/${ASSET}.tar.gz" \ | |
| "release/${ASSET}.tar.gz.sha256" \ | |
| --clobber |