-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (163 loc) · 6.89 KB
/
create-artifacts.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: Create artifacts
on:
push:
tags:
- "v*.*.*"
- "v*.*.*-*"
workflow_dispatch:
inputs:
linux:
description: "Create artifacts for Linux"
required: false
type: boolean
default: true
windows:
description: "Create artifacts for Windows"
required: false
type: boolean
default: true
macos:
description: "Create artifacts for macOS"
required: false
type: boolean
default: true
permissions:
contents: read
jobs:
create-linux-artifacts:
name: Create Linux artifacts
if: ${{ github.event_name == 'workflow_dispatch' && inputs.linux == true || github.event_name == 'push'}}
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker
uses: docker/setup-docker-action@v4
with:
daemon-config: |
{
"debug": true,
"features": {
"containerd-snapshotter": true
}
}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.artifacts
context: ./
platforms: linux/amd64,linux/arm64
load: true
tags: fediproto-sync-artifacts:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract compiled artifacts
shell: bash
run: |
mkdir -p ${{ github.workspace }}/artifacts;
docker run --volume "./artifacts:/artifacts" --platform "linux/amd64" --rm "fediproto-sync-artifacts:latest" /bin/bash -c "cp -r /tmp/fediproto-sync/** /artifacts";
docker run --volume "./artifacts:/artifacts" --platform "linux/arm64" --rm "fediproto-sync-artifacts:latest" /bin/bash -c "cp -r /tmp/fediproto-sync/** /artifacts";
- name: Create artifact (Linux - x64)
uses: actions/upload-artifact@v4
with:
name: "fediproto-sync_linux-amd64_${{ github.ref_type == 'tag' && github.ref_name || github.sha }}"
path: ${{ github.workspace }}/artifacts/linux_amd64/**/*
if-no-files-found: error
- name: Create artifact (Linux - arm64)
uses: actions/upload-artifact@v4
with:
name: "fediproto-sync_linux-arm64_${{ github.ref_type == 'tag' && github.ref_name || github.sha }}"
path: ${{ github.workspace }}/artifacts/linux_arm64/**/*
if-no-files-found: error
create-windows-artifacts:
name: Create Windows artifacts
if: ${{ github.event_name == 'workflow_dispatch' && inputs.windows == true || github.event_name == 'push' }}
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- name: Install targets
shell: pwsh
run: |
rustup target add x86_64-pc-windows-msvc;
# rustup target add aarch64-pc-windows-msvc;
- name: Build
shell: pwsh
env:
FEDIPROTOSYNC_INCLUDE_COMMIT_HASH: "false"
FEDIPROTOSYNC_UPDATE_MANIFEST_VERSION: "true"
run: |
cargo build --release --target "x86_64-pc-windows-msvc";
# cargo build --release --target "aarch64-pc-windows-msvc";
$null = New-Item -Path "${{ github.workspace }}/artifacts" -ItemType "Directory";
$null = New-Item -Path "${{ github.workspace }}/artifacts/windows_amd64" -ItemType "Directory";
# $null = New-Item -Path "${{ github.workspace }}/artifacts/windows_arm64" -ItemType "Directory";
Copy-Item -Path "${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/fediproto-sync.exe" -Destination "${{ github.workspace }}/artifacts/windows_amd64/fediproto-sync.exe";
# Copy-Item -Path "${{ github.workspace }}/target/aarch64-pc-windows-msvc/release/fediproto-sync.exe" -Destination "${{ github.workspace }}/artifacts/windows_arm64/fediproto-sync.exe";
- name: Create artifact (Windows - x64)
uses: actions/upload-artifact@v4
with:
name: "fediproto-sync_windows-amd64_${{ github.ref_type == 'tag' && github.ref_name || github.sha }}"
path: ${{ github.workspace }}/artifacts/windows_amd64/**/*
if-no-files-found: error
# - name: Create artifact (Windows - arm64)
# uses: actions/upload-artifact@v4
# with:
# name: "fediproto-sync_windows-arm64_${{ github.ref_type == 'tag' && github.ref_name || github.sha }}"
# path: ${{ github.workspace }}/artifacts/windows_arm64/**/*
# if-no-files-found: error
create-macos-artifacts:
name: Create macOS artifacts
if: ${{ github.event_name == 'workflow_dispatch' && inputs.macos == true || github.event_name == 'push' }}
runs-on: macos-14
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- name: Install targets
shell: bash
run: |
rustup target add x86_64-apple-darwin;
rustup target add aarch64-apple-darwin;
- name: Build
shell: bash
env:
FEDIPROTOSYNC_INCLUDE_COMMIT_HASH: "false"
FEDIPROTOSYNC_UPDATE_MANIFEST_VERSION: "true"
run: |
cargo build --release --target "x86_64-apple-darwin";
mkdir -p "${{ github.workspace }}/artifacts/macos_amd64";
cp "${{ github.workspace }}/target/x86_64-apple-darwin/release/fediproto-sync" "${{ github.workspace }}/artifacts/macos_amd64/fediproto-sync";
cargo build --release --target "aarch64-apple-darwin";
mkdir -p "${{ github.workspace }}/artifacts/macos_arm64";
cp "${{ github.workspace }}/target/aarch64-apple-darwin/release/fediproto-sync" "${{ github.workspace }}/artifacts/macos_arm64/fediproto-sync";
- name: Create artifact (macOS - x64)
uses: actions/upload-artifact@v4
with:
name: "fediproto-sync_macos-amd64_${{ github.ref_type == 'tag' && github.ref_name || github.sha }}"
path: ${{ github.workspace }}/artifacts/macos_amd64/**/*
if-no-files-found: error
- name: Create artifact (macOS - arm64)
uses: actions/upload-artifact@v4
with:
name: "fediproto-sync_macos-arm64_${{ github.ref_type == 'tag' && github.ref_name || github.sha }}"
path: ${{ github.workspace }}/artifacts/macos_arm64/**/*
if-no-files-found: error