-
Notifications
You must be signed in to change notification settings - Fork 2
114 lines (104 loc) · 3.29 KB
/
build_release.yaml
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
name: build_release
on:
push:
tags:
- "v*.*.*"
jobs:
build_binary:
name: Build for ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
name: x86_64
tag: x86_64-musl
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
name: aarch64
tag: aarch64-musl
target: aarch64-unknown-linux-musl
steps:
- name: "Checkout"
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "Cache builder image"
id: cache-builder-image
uses: actions/cache@v3
with:
path: musl-builder-image-${{ matrix.name }}
key: musl-builder-image-${{ matrix.name }}
- name: "Pull and save builder image"
if: steps.cache-builder-image.outputs.cache-hit != 'true'
run: |
docker pull messense/rust-musl-cross:${{ matrix.tag }}
docker save messense/rust-musl-cross:${{ matrix.tag }} -o musl-builder-image-${{ matrix.name }}
- name: "Load builder image"
run: docker load -i musl-builder-image-${{ matrix.name }}
- name: "Cache Rust"
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.name }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: "Build binary"
run: docker run --rm -u root -v "$(pwd)":/home/rust/src messense/rust-musl-cross:${{ matrix.tag }} cargo build --release
- name: "Upload binary"
uses: actions/upload-artifact@v3
with:
name: tataki-${{ matrix.name }}
path: target/${{ matrix.target }}/release/tataki
create_release:
needs: [build_binary]
name: Create release for ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- name: x86_64
- name: aarch64
steps:
- name: "Download tataki binary"
uses: actions/download-artifact@v3
with:
name: tataki-${{ matrix.name }}
- name: Upload tataki binary
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: tataki
asset_name: tataki-${{ matrix.name }}
deploy_ghcr:
needs: [create_release]
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
with:
fetch-depth: 1
- 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
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/tataki:${{ github.ref_name }}
ghcr.io/${{ github.repository_owner }}/tataki:latest