-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (139 loc) · 5.02 KB
/
publish.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
name: Release
on:
workflow_dispatch: # manual trigger release
inputs:
create_release:
description: 'Create new release'
required: true
type: boolean
release_version:
description: "Version (e.g. 1.0.0)"
required: true
type: string
jobs:
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux-x86_64, macos-x86_64, macos-arm64]
include:
- build: linux-x86_64
os: ubuntu-20.04
rust: nightly
target: x86_64-unknown-linux-gnu
archive-name: server-assistant-x86_64-unknown-linux-gnu.tar.gz
bin-path: linux-x86_64-binary
- build: macos-x86_64
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
archive-name: server-assistant-x86_64-apple-darwin.tar.gz
bin-path: macos-x86_64-binary
- build: macos-arm64
os: macos-latest
rust: nightly
target: aarch64-apple-darwin
archive-name: server-assistant-aarch64-apple-darwin.tar.gz
bin-path: macos-arm64-binary
fail-fast: false
steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install dependencies
if: matrix.build == 'linux-x86_64'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev pkg-config
rustup target add ${{ matrix.target }}
- name: Build binary
run: cargo build --verbose --release --target ${{ matrix.target }}
env:
RUST_BACKTRACE: 1
- name: Strip binary (linux and macos)
if: matrix.build == 'linux-x86_64' || matrix.build == 'macos-x86_64' || matrix.build == 'macos-arm64'
run: |
strip "target/${{ matrix.target }}/release/kw-search-server"
ls -al "target/${{ matrix.target }}/release/kw-search-server"
- name: Build archive
shell: bash
run: |
mkdir archive
# cp LICENSE README.md archive/
cd archive
if [ "${{ matrix.build }}" = "windows" ]; then
cp "../target/${{ matrix.target }}/release/kw-search-server.exe" ./
7z a "${{ matrix.archive-name }}" kw-search-server.exe
fi
if [ "${{ matrix.build }}" = "linux-x86_64" ]; then
cp "../target/${{ matrix.target }}/release/kw-search-server" ./
sha256sum kw-search-server > SHA256SUM
echo "Debug info(SHA256SUM):"
cat SHA256SUM
tar -czf "${{ matrix.archive-name }}" SHA256SUM kw-search-server
fi
if [ "${{ matrix.build }}" = "macos-x86_64" ] || [ "${{ matrix.build }}" = "macos-arm64" ]; then
cp "../target/${{ matrix.target }}/release/kw-search-server" ./
shasum -a 256 kw-search-server > SHA256SUM
echo "Debug info(SHA256SUM):"
cat SHA256SUM
tar -czf "${{ matrix.archive-name }}" SHA256SUM kw-search-server
fi
ls -al
- name: Upload archive
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.bin-path }}
path: archive/${{ matrix.archive-name }}
release:
name: release
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: linux-x86_64-binary
path: linux-x86_64-binary
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: macos-x86_64-binary
path: macos-x86_64-binary
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: macos-arm64-binary
path: macos-arm64-binary
- name: Display structure of downloaded files
run: |
ls -al
ls -al linux-x86_64-binary
ls -al macos-x86_64-binary
ls -al macos-arm64-binary
- name: Tag and release names
id: tag_and_release_names
run: |
echo "tag_name=${{ github.event.inputs.release_version }}" >> $GITHUB_OUTPUT
echo "release_name=kw-search-server ${{ github.event.inputs.release_version }}" >> $GITHUB_OUTPUT
- name: Create Release and Upload Release Asset
if: ${{ github.event.inputs.create_release == 'true' && github.ref == 'refs/heads/main'}}
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.tag_and_release_names.outputs.release_name }}
tag_name: ${{ steps.tag_and_release_names.outputs.tag_name }}
body: TODO New Release.
draft: true
prerelease: true
files: |
linux-x86_64-binary/*
macos-x86_64-binary/*
macos-arm64-binary/*