-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (118 loc) · 4.41 KB
/
release.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
on:
push:
tags:
- "v*.*.*"
name: Release
env:
RUST_TOOLCHAIN: 1.79.0
jobs:
build:
name: Build binary
strategy:
matrix:
include:
- arch: x86_64-unknown-linux-gnu
os: ubuntu-22.04
file_name: elasticnow-${{ github.ref_name }}-linux-amd64
file_ext: .tar.gz
- arch: x86_64-unknown-linux-musl
os: ubuntu-22.04
file_name: elasticnow-${{ github.ref_name }}-linux-amd64-musl
file_ext: .tar.gz
- arch: aarch64-unknown-linux-gnu
os: ubuntu-22.04
file_name: elasticnow-${{ github.ref_name }}-linux-arm64
file_ext: .tar.gz
- arch: x86_64-apple-darwin
os: macos-latest
file_name: elasticnow-${{ github.ref_name }}-darwin-amd64
file_ext: .tar.gz
- arch: aarch64-apple-darwin
os: macos-latest
file_name: elasticnow-${{ github.ref_name }}-darwin-arm64
file_ext: .tar.gz
- arch: x86_64-pc-windows-msvc
os: windows-2022
file_name: elasticnow-${{ github.ref_name }}-windows-amd64
file_ext: .zip
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache cargo assets
id: cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.arch }}-build-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install dependencies for linux
if: contains(matrix.arch, 'linux')
run: |
sudo apt-get -y update
sudo apt-get -y install --reinstall libssl-dev pkg-config g++-aarch64-linux-gnu gcc-aarch64-linux-gnu musl-dev musl-tools
sudo ln -s "/usr/bin/g++" "/usr/bin/musl-g++"
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
target: ${{ matrix.arch }}
- name: Output package versions
run: |
cargo version ; rustc --version ; gcc --version ; g++ --version
- name: Install cross
if: contains(matrix.arch, 'linux')
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Print rustc cfg
run: rustc -C target-cpu=native --print cfg
- name: Run cargo build
if: contains(matrix.arch, 'linux') == false
run: cargo build --release --target ${{ matrix.arch }}
- name: Run cross build
if: contains(matrix.arch, 'linux')
run: cross build --release --target ${{ matrix.arch }}
- name: Calculate checksum and rename binary
if: contains(matrix.arch, 'windows') == false
shell: bash
run: |
cd target/${{ matrix.arch }}/release
chmod +x elasticnow
tar -zcvf ${{ matrix.file_name }}.tar.gz elasticnow
echo $(shasum -a 256 ${{ matrix.file_name }}.tar.gz | cut -f1 -d' ') > ${{ matrix.file_name }}.tar.gz.sha256sum
- name: Calculate checksum and rename binary for windows
if: contains(matrix.arch, 'windows')
shell: bash
run: |
cd target/${{ matrix.arch }}/release
7z a -tzip ${{ matrix.file_name }}.zip elasticnow.exe
certutil.exe -hashfile ${{ matrix.file_name }}.zip sha256|head -n 2|tail -n 1 > ${{ matrix.file_name }}.zip.sha256sum
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.file_name }}
path: target/${{ matrix.arch }}/release/${{ matrix.file_name }}${{ matrix.file_ext }}
- name: Upload checksum of artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.file_name }}.sha256sum
path: target/${{ matrix.arch }}/release/${{ matrix.file_name }}${{ matrix.file_ext }}.sha256sum
release:
name: Release artifacts
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Publish release
uses: softprops/action-gh-release@v2
with:
name: "Release ${{ github.ref_name }}"
generate_release_notes: true
files: |
**/elasticnow-*