mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-17 09:33:38 -05:00
Optimize workflows (#25)
feat: optimize workflows --------- Co-authored-by: Stavros <steveiliop56@gmail.com>
This commit is contained in:
47
.github/workflows/ci.yml
vendored
Normal file
47
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: CI
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: "main"
|
||||
|
||||
jobs:
|
||||
build-binary:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Set up Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
|
||||
- name: Install deps
|
||||
run: cd web && bun install
|
||||
|
||||
- name: Build
|
||||
run: ./build.sh cargo build --verbose
|
||||
|
||||
build-image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
push: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
75
.github/workflows/nightly.yml
vendored
75
.github/workflows/nightly.yml
vendored
@@ -1,46 +1,48 @@
|
||||
name: Nightly Release
|
||||
on:
|
||||
push:
|
||||
branches: main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
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 }}
|
||||
build-binaries:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup rust
|
||||
- name: Set up 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: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Set up Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
|
||||
- name: Upload CLI
|
||||
- name: Install deps
|
||||
run: cd web && bun install
|
||||
|
||||
- name: Build amd64 binary
|
||||
run: |
|
||||
./build.sh cross build --target x86_x64-unknown-linux-musl --release
|
||||
mv target/x86_x64-unknown-linux-musl/release/cup ./cup-linux-amd64
|
||||
|
||||
- name: Build arm64 binary
|
||||
run: |
|
||||
./build.sh cross build --target aarch64-unknown-linux-musl --release
|
||||
mv target/aarch64-unknown-linux-musl/release/cup ./cup-linux-arm64
|
||||
|
||||
- name: Upload binaries
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.platform.name }}
|
||||
path: target/${{ matrix.platform.target }}/debug/${{ matrix.platform.bin }}
|
||||
name: binaries
|
||||
path: |
|
||||
cup-linux-amd64
|
||||
cup-linux-arm64
|
||||
|
||||
build-image:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -69,4 +71,21 @@ jobs:
|
||||
push: true
|
||||
tags: ghcr.io/sergi0g/cup:nightly
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
nightly-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-binaries
|
||||
steps:
|
||||
- name: Download binaries
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: binaries
|
||||
path: binaries
|
||||
|
||||
- uses: pyTooling/Actions/releaser@r0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: nightly
|
||||
rm: true
|
||||
files: binaries/*
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
name: Release
|
||||
on:
|
||||
push:
|
||||
tags: ["v*.*.*"]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
get-tag:
|
||||
@@ -12,34 +11,50 @@ jobs:
|
||||
- name: Get current tag
|
||||
id: tag
|
||||
run: |
|
||||
TAG=$(echo "$GITHUB_REF" | sed 's/^refs\/tags\///')
|
||||
TAG=v$(head -n 4 Cargo.toml | grep version | awk '{print $3}' | tr -d '"')
|
||||
echo "Current tag: $TAG"
|
||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||
build-binary:
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- aarch64
|
||||
- x86_64
|
||||
|
||||
build-binaries:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup rust
|
||||
- name: Set up 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: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Upload binary
|
||||
- name: Set up Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
|
||||
- name: Install deps
|
||||
run: cd web && bun install
|
||||
|
||||
- name: Build amd64 binary
|
||||
run: |
|
||||
./build.sh cross build --target x86_x64-unknown-linux-musl --release
|
||||
mv target/x86_x64-unknown-linux-musl/release/cup ./cup-linux-amd64
|
||||
|
||||
- name: Build arm64 binary
|
||||
run: |
|
||||
./build.sh cross build --target aarch64-unknown-linux-musl --release
|
||||
mv target/aarch64-unknown-linux-musl/release/cup ./cup-linux-arm64
|
||||
|
||||
- name: Upload binaries
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cup-linux-${{ matrix.arch }}
|
||||
path: target/${{ matrix.arch }}-unknown-linux-musl/release/cup
|
||||
name: binaries
|
||||
path: |
|
||||
cup-linux-amd64
|
||||
cup-linux-arm64
|
||||
|
||||
build-image:
|
||||
needs: get-tag
|
||||
@@ -73,24 +88,13 @@ jobs:
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get-tag, build-image, build-binary]
|
||||
needs: [get-tag, build-image, build-binaries]
|
||||
steps:
|
||||
- name: Download arm64 binary
|
||||
- name: Download binaries
|
||||
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 /home/runner/work/cup/cup/cup-linux-aarch64 && mv /home/runner/work/cup/cup/cup cup-linux-aarch64
|
||||
# unzip /home/runner/work/cup/cup/cup-linux-x86_64 && mv /home/runner/work/cup/cup/cup cup-linux-x86_64
|
||||
name: binaries
|
||||
path: binaries
|
||||
|
||||
- name: Create release
|
||||
uses: softprops/action-gh-release@v2
|
||||
@@ -100,6 +104,4 @@ jobs:
|
||||
prerelease: true
|
||||
tag_name: ${{ needs.get-tag.outputs.tag }}
|
||||
name: ${{ needs.get-tag.outputs.tag }}
|
||||
files: |
|
||||
cup-linux-aarch64
|
||||
cup-linux-x86_64
|
||||
files: binaries/*
|
||||
Reference in New Issue
Block a user