m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-14 08:03:48 -05:00

Update workflows

This commit is contained in:
Sergio
2024-07-10 19:44:55 +03:00
parent 4ec661183f
commit ac8f97fbcd
4 changed files with 88 additions and 31 deletions

View File

@@ -1,27 +1,60 @@
name: Build docker image name: Release
on: on:
release: push:
types: tags: ["v*.*.*"]
- published
env:
CARGO_TERM_COLOR: always
jobs: jobs:
build: get-tag:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Get current tag
uses: actions/checkout@v3 run: |
TAG=$(echo "$GITHUB_REF" | sed 's/^refs\/tags\///')
echo "Current tag: $TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
build-binary:
strategy:
matrix:
platform:
- release_for: linux-aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-musl
bin: cup
name: cup-linux-aarch64
command: build
- name: Get latest release tag - release_for: linux-x86_64
id: release os: ubuntu-latest
uses: pozetroninc/github-action-get-latest-release@master target: x86_64-unknown-linux-musl
bin: cup
name: cup-linux-x86_64
command: build
runs-on: ${{ matrix.platform.os }}
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 ${{ matrix.platform.command }} --target ${{ matrix.platform.target }} --release
- name: Upload binary
uses: actions/upload-artifact@v4
with: with:
owner: sergi0g name: ${{ matrix.platform.name }}
repo: cup path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
excludes: prerelease, draft
build-image:
needs: get-tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@@ -33,17 +66,41 @@ jobs:
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push - name: Build and push image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v6
with: with:
context: . context: .
platforms: linux/amd64, linux/arm64
push: true push: true
platforms: linux/amd64,linux/arm64 tags: ghcr.io/sergi0g/cup:${{ needs.get-tag.outputs.tag }}
tags: |
ghcr.io/sergi0g/cup:latest release:
ghcr.io/sergi0g/cup:${{ steps.release.outputs.release }} runs-on: ubuntu-latest
cache-from: type=gha needs: [get-tag, build-image, build-binary]
cache-to: type=gha,mode=max 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: 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-aarch64
cup-linux-x86_64/cup-linux-x86_64

View File

@@ -3,7 +3,7 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
tag: tag:
description: "Nightly version tag (1, 2, 3...)" description: "Nightly version tag"
required: true required: true
jobs: jobs:
@@ -56,7 +56,7 @@ jobs:
run: cargo install cross --git https://github.com/cross-rs/cross run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build binary - name: Build binary
run: cross ${{ matrix.platform.command }} --target ${{ matrix.platform.target }} --release run: cross ${{ matrix.platform.command }} --target ${{ matrix.platform.target }}
- name: Upload CLI - name: Upload CLI
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -65,7 +65,7 @@ jobs:
path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
build-image: build-image:
needs: [create-tag, build-binary] needs: create-tag
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout

2
Cargo.lock generated
View File

@@ -350,7 +350,7 @@ dependencies = [
[[package]] [[package]]
name = "cup" name = "cup"
version = "0.1.0" version = "1.1.2"
dependencies = [ dependencies = [
"bollard", "bollard",
"clap", "clap",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cup" name = "cup"
version = "1.1.1" version = "1.1.2"
edition = "2021" edition = "2021"
[dependencies] [dependencies]