sculptor/.github/workflows/release.yml
Jonatan Czarniecki cbb31f2183
minor refactor
- simplify CSV reading logic
- add more comments
- rework the packaging script
- remove debug information for git tags
2025-06-08 15:57:24 +02:00

147 lines
No EOL
3.9 KiB
YAML

name: Release
run-name: Release ${{ github.ref_name }}
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
packages: write
env:
RUST_VERSION: 1.87
ZIG_VERSION: 0.14.1
ALPINE_VERSION: 3.22
CARGO_TERM_COLOR: always
CARGO_BUILD_TARGETS: x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu,x86_64-pc-windows-gnu
jobs:
build-binary:
name: Build binaries and upload them as artifacts
runs-on: ubuntu-latest
env:
OUTPUT_DIR: target/output
outputs:
binary-artifact-id: ${{ steps.artifact-upload.outputs.artifact-id }}
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Use build cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "cargo-v0"
cache-all-crates: true
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: ${{ env.CARGO_BUILD_TARGETS }}
# needed if we want to use linting in build action
# components: clippy, rustfmt
- name: Install the build dependencies
uses: ./.github/actions/dependencies
with:
zig-version: ${{ env.ZIG_VERSION }}
- name: Build the project
uses: ./.github/actions/build
with:
targets: ${{ env.CARGO_BUILD_TARGETS }}
lint: false
- name: Package the artifacts
run: mkdir -p "$OUTPUT_DIR" && \
./.github/scripts/package-artifacts.sh
- name: Upload artifact
id: artifact-upload
uses: actions/upload-artifact@v4
with:
path: ${{ env.OUTPUT_DIR }}/*
name: binaries-${{ github.ref_name }}
build-image:
name: Build image and push to GHCR
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
# if we wanted to push to DockerHub:
# - name: Login to DockerHub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# also uncomment the tags parameter in the last step
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
- name: Set up buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
build-args: |
ALPINE_VERSION
RUST_VERSION
platforms: linux/amd64,linux/arm64
# push: true
tags: |
ghcr.io/${{ github.repository_owner }}/sculptor:latest
ghcr.io/${{ github.repository_owner }}/sculptor:${{ github.ref_name }}
# ${{ github.repository_owner }}/sculptor:latest
# ${{ github.repository_owner }}/sculptor:${{ github.ref_name }}
provenance: false
sbom: false
cache-from: type=gha
cache-to: type=gha,mode=max
create-release:
name: Create GitHub release
needs:
- build-binary
- build-image
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-tags: true
ref: ${{ github.ref }}
- name: Download the artifacts
uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.build-binary.outputs.binary-artifact-id }}
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ github.ref_name }} \
--verify-tag \
--generate-notes \
--latest \
--draft \
binaries-${{ github.ref_name }}/*