-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (106 loc) · 3.43 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Build Docker Image
on:
push:
branches: ["main"]
paths: ["**/*.rs", "**/*.toml", "**/*.lock"]
workflow_dispatch:
inputs:
skip-build:
type: boolean
description: "Skip build step"
default: false
required: false
jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
if: ${{ !github.event.inputs.skip-build }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: "aarch64-unknown-linux-musl,x86_64-unknown-linux-musl"
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install dependencies
working-directory: /tmp
run: |
wget https://musl.cc/aarch64-linux-musl-cross.tgz --quiet
tar -xf aarch64-linux-musl-cross.tgz -C . && rm aarch64-linux-musl-cross.tgz
- name: Build Binary
env:
RUSTFLAGS: "-C target-feature=+crt-static"
run: |
mkdir -p binaries/linux/{arm64,amd64}
export PATH=$PATH:/tmp/aarch64-linux-musl-cross/bin
cargo build --release --target aarch64-unknown-linux-musl
mv target/aarch64-unknown-linux-musl/release/berry-pasty binaries/linux/arm64/berry-pasty
cargo build --release --target x86_64-unknown-linux-musl
mv target/x86_64-unknown-linux-musl/release/berry-pasty binaries/linux/amd64/berry-pasty
pwd && ls -lhR binaries
- name: Upload binary for aarch64
uses: actions/upload-artifact@v4
with:
name: berry-pasty-aarch64-linux64-musl
path: binaries/linux/arm64/berry-pasty
- name: Upload binary for x86_64
uses: actions/upload-artifact@v4
with:
name: berry-pasty-x86_64-linux64-musl
path: binaries/linux/amd64/berry-pasty
- name: Docker setup QEMU
uses: docker/setup-qemu-action@v3
- name: Docker setup Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: gztime
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
gztime/berry-pasty
tags: |
latest
- name: Publish images
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true
prune:
name: Prune old packages
runs-on: ubuntu-latest
needs: build
if: always()
permissions:
contents: read
packages: write
steps:
- name: Prune old packages
uses: dataaxiom/ghcr-cleanup-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
exclude-tags: latest
validate: true
dry-run: false
delete-untagged: true
delete-ghost-images: true
delete-partial-images: true