mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-09 13:43:49 -05:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f88f7d90f9 | ||
|
|
75700cd692 | ||
|
|
6573b43ce0 | ||
|
|
bee808e577 | ||
|
|
ac8f97fbcd | ||
|
|
4ec661183f | ||
|
|
39b2355c04 | ||
|
|
867ab4ba10 | ||
|
|
9a75f5101f | ||
|
|
54eed353aa | ||
|
|
e3319d9371 | ||
|
|
38d775688a | ||
|
|
31dd605efb |
116
.github/workflows/build.yml
vendored
116
.github/workflows/build.yml
vendored
@@ -1,27 +1,63 @@
|
|||||||
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
|
||||||
|
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:
|
||||||
|
platform:
|
||||||
|
- release_for: linux-aarch64
|
||||||
|
os: ubuntu-latest
|
||||||
|
target: aarch64-unknown-linux-musl
|
||||||
|
bin: cup
|
||||||
|
name: cup-linux-aarch64
|
||||||
|
command: build
|
||||||
|
|
||||||
|
- release_for: linux-x86_64
|
||||||
|
os: ubuntu-latest
|
||||||
|
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:
|
||||||
|
name: ${{ matrix.platform.name }}
|
||||||
|
path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
|
||||||
|
|
||||||
|
build-image:
|
||||||
|
needs: get-tag
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Get latest release tag
|
|
||||||
id: release
|
|
||||||
uses: pozetroninc/github-action-get-latest-release@master
|
|
||||||
with:
|
|
||||||
owner: sergi0g
|
|
||||||
repo: cup
|
|
||||||
excludes: prerelease, draft
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
@@ -33,17 +69,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: .
|
||||||
push: true
|
|
||||||
platforms: linux/amd64, linux/arm64
|
platforms: linux/amd64, linux/arm64
|
||||||
tags: |
|
push: true
|
||||||
ghcr.io/sergi0g/cup:latest
|
tags: ghcr.io/sergi0g/cup:${{ needs.get-tag.outputs.tag }},ghcr.io/sergi0g/cup:latest
|
||||||
ghcr.io/sergi0g/cup:${{ steps.release.outputs.release }}
|
|
||||||
cache-from: type=gha
|
release:
|
||||||
cache-to: type=gha,mode=max
|
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: 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
|
||||||
|
|||||||
121
.github/workflows/nightly.yml
vendored
Normal file
121
.github/workflows/nightly.yml
vendored
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
name: Nightly Release
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: "Nightly version tag"
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
tagname: ${{ steps.get_tag.outputs.tagname }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get tag from Cargo.toml
|
||||||
|
id: get_tag
|
||||||
|
run: |
|
||||||
|
VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')
|
||||||
|
echo "tagname=v$VERSION-nightly.${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- uses: rickstaa/action-create-tag@v1
|
||||||
|
with:
|
||||||
|
tag: ${{ steps.get_tag.outputs.tagname }}
|
||||||
|
|
||||||
|
build-binary:
|
||||||
|
needs: create-tag
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- release_for: linux-aarch64
|
||||||
|
os: ubuntu-latest
|
||||||
|
target: aarch64-unknown-linux-musl
|
||||||
|
bin: cup
|
||||||
|
name: cup-linux-aarch64
|
||||||
|
command: build
|
||||||
|
|
||||||
|
- release_for: linux-x86_64
|
||||||
|
os: ubuntu-latest
|
||||||
|
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 }}
|
||||||
|
|
||||||
|
- name: Upload CLI
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.platform.name }}
|
||||||
|
path: target/${{ matrix.platform.target }}/debug/${{ matrix.platform.bin }}
|
||||||
|
|
||||||
|
build-image:
|
||||||
|
needs: create-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.create-tag.outputs.tagname }}
|
||||||
|
|
||||||
|
nightly-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [create-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: Create nightly release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
prerelease: true
|
||||||
|
tag_name: ${{ needs.create-tag.outputs.tagname }}
|
||||||
|
name: ${{ needs.create-tag.outputs.tagname }}
|
||||||
|
files: |
|
||||||
|
cup-linux-aarch64/cup-linux-aarch64
|
||||||
|
cup-linux-x86_64/cup-linux-x86_64
|
||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -350,7 +350,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cup"
|
name = "cup"
|
||||||
version = "0.1.0"
|
version = "1.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bollard",
|
"bollard",
|
||||||
"clap",
|
"clap",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cup"
|
name = "cup"
|
||||||
version = "0.1.0"
|
version = "1.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
12
Dockerfile
12
Dockerfile
@@ -3,12 +3,16 @@ WORKDIR /
|
|||||||
|
|
||||||
RUN apk add musl-dev
|
RUN apk add musl-dev
|
||||||
|
|
||||||
RUN USER=root cargo new cup
|
RUN USER=root cargo new --bin cup
|
||||||
WORKDIR /cup
|
WORKDIR /cup
|
||||||
COPY Cargo.toml Cargo.lock ./
|
|
||||||
RUN cargo build --release
|
|
||||||
|
|
||||||
COPY src ./src
|
COPY Cargo.toml Cargo.lock .
|
||||||
|
RUN cargo build --release
|
||||||
|
RUN rm -rf src/
|
||||||
|
|
||||||
|
COPY src src
|
||||||
|
# This is a very bad workaround, but cargo only triggers a rebuild this way for some reason
|
||||||
|
RUN printf "\n" >> src/main.rs
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|||||||
Reference in New Issue
Block a user