-
Notifications
You must be signed in to change notification settings - Fork 28
162 lines (141 loc) · 4.22 KB
/
deploy.yml
File metadata and controls
162 lines (141 loc) · 4.22 KB
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
name: Deploy
on:
workflow_dispatch:
inputs:
new_version:
description: New version to deploy
required: true
type: string
env:
BIN_NAME: cotp
PROJECT_NAME: cotp
REPO_NAME: replydev/cotp
jobs:
dist:
name: Dist
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false # don't fail other jobs if one fails
matrix:
build:
[
x86_64-linux,
aarch64-linux,
x86_64-macos,
aarch64-macos,
x86_64-win-msvc,
]
include:
- build: x86_64-linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- build: aarch64-linux
os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- build: x86_64-macos
os: macos-latest
target: x86_64-apple-darwin
- build: aarch64-macos
os: macos-latest
target: aarch64-apple-darwin
- build: x86_64-win-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
# Cache dependencies
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}-release
- name: Install Dependencies for Linux
if: contains(matrix.build, 'linux')
run: sudo apt update && sudo apt install -y libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
- name: Build release binary
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
mkdir dist
if [ "${{ matrix.os }}" == *"windows"* ]; then
cp "target/${{ matrix.target }}/release/$BIN_NAME.exe" "dist/"
else
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/"
fi
- uses: actions/upload-artifact@v7.0.0
with:
name: cotp-${{ matrix.build }}
path: dist
publish:
name: "Publish binaries to release page"
needs: [dist]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v6
with:
submodules: false
- uses: actions/download-artifact@v8
- run: ls -al cotp-*
- name: Build archive
shell: bash
env:
NEW_VERSION: ${{ inputs.new_version }}
run: |
set -ex
rm -rf tmp
mkdir tmp
mkdir dist
for dir in cotp-* ; do
platform=${dir#"cotp-"}
unset exe
# If platform contains "win" then append .exe to the filename
if [[ "$platform" == *"win"* ]]; then
exe=".exe"
fi
pkgname=$PROJECT_NAME-$NEW_VERSION-$platform
mkdir tmp/$pkgname
# cp LICENSE README.md tmp/$pkgname
mv cotp-$platform/$BIN_NAME$exe tmp/$pkgname
chmod +x tmp/$pkgname/$BIN_NAME$exe
if [ "$exe" = "" ]; then
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
else
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
fi
done
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
file_glob: true
tag: v${{ inputs.new_version }}
overwrite: true
publish_on_cargo_crates:
name: "Publish crate on crates.io"
needs: [dist]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout sources
uses: actions/checkout@v6
with:
submodules: false
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Login
run: cargo login ${{ secrets.CRATE_AUTH_TOKEN }}
- name: List
run: cargo package --list
- name: Publish
run: cargo publish