-
Notifications
You must be signed in to change notification settings - Fork 84
134 lines (114 loc) · 3.79 KB
/
release-linux.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
125
126
127
128
129
130
131
132
133
134
name: Release binaries for Linux and Docker
on:
push:
branches:
- main
tags:
- "v*.*.*"
jobs:
build-docker-cross:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
platform: [linux/arm/v7, linux/amd64, linux/arm64]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: builder1
- name: Cache
uses: actions/cache@v4
id: cache
with:
path: |
usr-local-cargo-git-db
usr-local-cargo-registry-cache
usr-local-cargo-registry-index
src-target
key: docker-xx-v1-${{ matrix.platform }}-release
save-always: true
- name: inject cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"usr-local-cargo-git-db": "/usr/local/cargo/git/db",
"usr-local-cargo-registry-cache": "/usr/local/cargo/registry/cache",
"usr-local-cargo-registry-index": "/usr/local/cargo/registry/index",
"src-target": "/src/target"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: cross-compile the binary
run: |
set -e
mkdir -p target/cross
docker buildx ls
mkdir -p target/cross/${{ matrix.platform }}
docker build --builder ${{ steps.builder1.outputs.name }} \
--platform ${{ matrix.platform }} \
-f docker/Dockerfile.xx \
--output type=local,dest=target/cross/${{ matrix.platform }} ./
- name: list files
run: find target/cross/
- name: generate-archive-key
id: gen_artifact_key
run: |
echo "key=$(echo ${{ matrix.platform }} | tr '/' '-')" >> "$GITHUB_OUTPUT"
- name: copy binary for release
run: |
cd target/cross
cp -l ${{ matrix.platform }}/rqbit rqbit-${{ steps.gen_artifact_key.outputs.key }}
- uses: softprops/action-gh-release@v1
if: ${{ github.ref_type == 'tag' }}
with:
generate_release_notes: true
files: |
target/cross/rqbit-${{ steps.gen_artifact_key.outputs.key }}
- name: Archive target/cross/
uses: actions/upload-artifact@v4
with:
name: ${{ steps.gen_artifact_key.outputs.key }}
path: target/cross/${{ matrix.platform }}/rqbit
build-push-docker-multiarch:
runs-on: ubuntu-latest
needs: build-docker-cross
steps:
- uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ikatson/rqbit
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: actions/download-artifact@v4
with:
name: linux-arm-v7
path: target/cross/linux/arm/v7/
- uses: actions/download-artifact@v4
with:
name: linux-arm64
path: target/cross/linux/arm64/
- uses: actions/download-artifact@v4
with:
name: linux-amd64
path: target/cross/linux/amd64/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
context: target/cross/
file: docker/Dockerfile