New version #23
Workflow file for this run
This file contains 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*.*.*"] | |
jobs: | |
get-tag: | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.tag.outputs.tag }} | |
steps: | |
- name: Get current tag | |
id: tag | |
run: | | |
TAG=$(echo "$GITHUB_REF" | sed 's/^refs\/tags\///') | |
echo "Current tag: $TAG" | |
echo "tag=$TAG" >> $GITHUB_OUTPUT | |
build-binary: | |
strategy: | |
matrix: | |
arch: | |
- aarch64 | |
- x86_64 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Install cross | |
run: cargo install cross --git https://github.com/cross-rs/cross | |
- name: Build binary | |
run: cross build --target ${{ matrix.arch }}-unknown-linux-musl --release | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cup-linux-${{ matrix.arch }} | |
path: target/${{ matrix.arch }}-unknown-linux-musl/release/cup | |
build-image: | |
needs: get-tag | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64, linux/arm64 | |
push: true | |
tags: ghcr.io/sergi0g/cup:${{ needs.get-tag.outputs.tag }},ghcr.io/sergi0g/cup:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
release: | |
runs-on: ubuntu-latest | |
needs: [get-tag, build-image, build-binary] | |
steps: | |
- name: Download arm64 binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: cup-linux-aarch64 | |
path: cup-linux-aarch64 | |
- name: Download x86 binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: cup-linux-x86_64 | |
path: cup-linux-x86_64 | |
- name: Extract and rename binaries | |
run: | | |
unzip cup-linux-aarch64.zip && mv cup cup-linux-aarch64 | |
unzip cup-linux-x86_64.zip && mv cup cup-linux-x86_64 | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
prerelease: true | |
tag_name: ${{ needs.get-tag.outputs.tag }} | |
name: ${{ needs.get-tag.outputs.tag }} | |
files: | | |
cup-linux-aarch64 | |
cup-linux-x86_64 |