-
Notifications
You must be signed in to change notification settings - Fork 2
162 lines (140 loc) · 5.7 KB
/
cd.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
name: CD
on:
push:
branches:
- main
jobs:
release-please:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
envx_version: ${{ env.ENVX_VERSION }}
build: ${{ env.BUILD }}
steps:
- name: Release Please
uses: GoogleCloudPlatform/release-please-action@v3
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: rust
- name: Set SemVer String
id: set-semver
if: steps.release.outputs.release_created == 'true'
run: |
echo "ENVX_VERSION=${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}" >> $GITHUB_ENV
echo "BUILD=true" >> $GITHUB_ENV
build-release:
name: Build Release
needs: [release-please]
if: needs.release-please.outputs.build == 'true'
permissions:
contents: write
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
# - target: i686-unknown-linux-musl
# os: ubuntu-latest
# install-musl: true
# - target: aarch64-unknown-linux-musl
# os: ubuntu-latest
# - target: arm-unknown-linux-musleabihf
# os: ubuntu-latest
- target: x86_64-apple-darwin
os: macOS-latest
- target: aarch64-apple-darwin
os: macOS-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
# - target: i686-pc-windows-msvc
# os: windows-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
# - target: i686-pc-windows-gnu
# os: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: install system dependencies
run: sudo apt update && sudo apt install -y make libssl-dev pkg-config
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: install musl
run: sudo apt install -y musl-tools musl-dev linux-headers-$(uname -r)
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
- name: install wget and make
run: sudo apt install -y wget make
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
- name: Install OpenSSL for x86 MUSL
run: |
sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm && ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic && ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux
sudo mkdir /musl
wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1f.tar.gz
tar zxf OpenSSL_1_1_1f.tar.gz
cd openssl-OpenSSL_1_1_1f/
CC="musl-gcc -fPIE -pie -static -idirafter /usr/include/ -idirafter /usr/include/x86_64-linux-gnu/" ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64
make depend
make -j$(nproc)
sudo make install
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}
if: ${{ matrix.target != 'x86_64-unknown-linux-musl' }}
- name: Build (MUSL)
run: OPENSSL_DIR=/musl OPENSSL_STATIC=true PKG_CONFIG_ALLOW_CROSS=1 cargo build --release --locked --target ${{ matrix.target }}
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
- name: Prepare binaries (zip) [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip envx.exe
7z a ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.zip envx.exe
cd -
- name: Prepare binaries (tar) [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip envx.exe
7z a -ttar archive.tar envx.exe
7z a -tgzip ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.tar.gz archive.tar
cd -
- name: Prepare binaries [-linux]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip envx || true
tar czvf ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.tar.gz envx
cd -
- name: Upload release archive
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.release-please.outputs.envx_version }}
files: envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}*
# - name: Install cargo-deb
# if: matrix.target == 'x86_64-unknown-linux-musl'
# run: cargo install cargo-deb
#
# - name: Generate .deb package file
# if: matrix.target == 'x86_64-unknown-linux-musl'
# run: cargo deb --target x86_64-unknown-linux-musl --output envx-${{ needs.release-please.outputs.envx_version }}-amd64.deb
#
# - name: Upload .deb package file
# if: matrix.target == 'x86_64-unknown-linux-musl'
# uses: svenstaro/upload-release-action@v2
# with:
# tag: ${{ needs.release-please.outputs.envx_version }}
# file: envx-${{ needs.release-please.outputs.envx_version }}-amd64.deb