name: Create GitHub Release on: push: tags: ["v*"] workflow_dispatch: inputs: version: description: "Version to release (e.g., 1.0.0)" required: true concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: release: name: Create GitHub Release runs-on: ubuntu-latest permissions: contents: write outputs: tag: ${{ steps.tag.outputs.TAG }} version: ${{ steps.tag.outputs.VERSION }} steps: - name: Free up disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /opt/ghc sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" echo "Disk space freed." - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 - name: Install uv uses: astral-sh/setup-uv@v7 - name: Set up Python run: uv python install 3.13 - name: Verify release branch if: github.event_name == 'workflow_dispatch' run: | if [ "${{ github.ref_name }}" != "main" ]; then echo "::error::Releases must be dispatched from main (current: ${{ github.ref_name }})" exit 1 fi - name: Ensure lockfiles are current run: | cp pyproject.toml _pyproject_orig.toml for variant in cpu rocm intel; do cp pyproject-${variant}.toml pyproject.toml uv lock cp uv.lock uv-${variant}.lock done cp _pyproject_orig.toml pyproject.toml uv lock rm _pyproject_orig.toml - name: Resolve tag name id: tag run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "TAG=v${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT" echo "VERSION=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT" else TAG="${GITHUB_REF_NAME}" echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" echo "VERSION=${TAG#v}" >> "$GITHUB_OUTPUT" fi - name: Create and push tag (workflow_dispatch only) if: github.event_name == 'workflow_dispatch' run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" TAG="${{ steps.tag.outputs.TAG }}" if git rev-parse "$TAG" >/dev/null 2>&1; then echo "Tag $TAG already exists, skipping creation." else git tag "$TAG" git push origin "$TAG" fi - name: Extract changelog for this version id: changelog run: | VERSION="${{ steps.tag.outputs.VERSION }}" if [ ! -f CHANGELOG.md ]; then echo "⚠️ CHANGELOG.md not found, using empty notes." echo "NOTES=" >> "$GITHUB_OUTPUT" exit 0 fi NOTES=$(awk "/^## \[$VERSION\]/{found=1; next} found && /^## \[/{exit} found{print}" CHANGELOG.md) if [ -z "$NOTES" ]; then echo "⚠️ No changelog entry found for version $VERSION." echo "NOTES=" >> "$GITHUB_OUTPUT" else { echo "NOTES<> "$GITHUB_OUTPUT" fi - name: Create GitHub Release uses: actions/github-script@v9 env: RELEASE_TAG: ${{ steps.tag.outputs.TAG }} RELEASE_NOTES: ${{ steps.changelog.outputs.NOTES }} with: script: | const tag = process.env.RELEASE_TAG; const notes = (process.env.RELEASE_NOTES || '').trim(); await github.rest.repos.createRelease({ owner: context.repo.owner, repo: context.repo.repo, tag_name: tag, name: `Release ${tag}`, body: notes || `Release ${tag}`, draft: false, prerelease: false, }); build-gpu: name: Build GPU image needs: release runs-on: ubuntu-latest permissions: packages: write steps: - name: Free up disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /opt/ghc sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" echo "Disk space freed." - name: Checkout uses: actions/checkout@v6 - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Log in to GHCR uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push GPU image (latest) uses: docker/build-push-action@v7 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: true build-args: VERSION=${{ needs.release.outputs.version }} cache-from: type=gha,scope=release-gpu cache-to: type=gha,mode=max,scope=release-gpu tags: | ghcr.io/sudolulo/winnow:latest ghcr.io/sudolulo/winnow:${{ needs.release.outputs.tag }} build-cpu: name: Build CPU image needs: release runs-on: ubuntu-latest permissions: packages: write steps: - name: Free up disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /opt/ghc sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" echo "Disk space freed." - name: Checkout uses: actions/checkout@v6 - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Log in to GHCR uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push CPU image uses: docker/build-push-action@v7 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: true build-args: | VARIANT=cpu VERSION=${{ needs.release.outputs.version }} cache-from: type=gha,scope=release-cpu cache-to: type=gha,mode=max,scope=release-cpu tags: | ghcr.io/sudolulo/winnow:cpu ghcr.io/sudolulo/winnow:${{ needs.release.outputs.tag }}-cpu build-rocm: name: Build ROCm image needs: release runs-on: ubuntu-latest permissions: packages: write steps: - name: Free up disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /opt/ghc sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" echo "Disk space freed." - name: Checkout uses: actions/checkout@v6 - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Log in to GHCR uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push ROCm image uses: docker/build-push-action@v7 with: context: . file: ./Dockerfile platforms: linux/amd64 push: true build-args: | VARIANT=rocm VERSION=${{ needs.release.outputs.version }} cache-from: type=gha,scope=release-rocm cache-to: type=gha,mode=max,scope=release-rocm tags: | ghcr.io/sudolulo/winnow:rocm ghcr.io/sudolulo/winnow:${{ needs.release.outputs.tag }}-rocm build-intel: name: Build Intel image needs: release runs-on: ubuntu-latest permissions: packages: write steps: - name: Free up disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /opt/ghc sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" echo "Disk space freed." - name: Checkout uses: actions/checkout@v6 - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Log in to GHCR uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Intel image uses: docker/build-push-action@v7 with: context: . file: ./Dockerfile platforms: linux/amd64 push: true build-args: | VARIANT=intel VERSION=${{ needs.release.outputs.version }} cache-from: type=gha,scope=release-intel cache-to: type=gha,mode=max,scope=release-intel tags: | ghcr.io/sudolulo/winnow:intel ghcr.io/sudolulo/winnow:${{ needs.release.outputs.tag }}-intel