-
Notifications
You must be signed in to change notification settings - Fork 16
245 lines (214 loc) · 9.91 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
on: workflow_dispatch
name: Create Release
env:
# Could, potentially automatically parse
# the bin name, but let's do it automatically for now.
RELEASE_BIN: cbsh
RELEASE_BIN_WINDOWS: cbsh.exe
# Space separated paths to include in the archive.
# Start relative paths with a dot if you don't want
# paths to be preserved. Use "/" as a delimiter.
RELEASE_ADDS: README.md LICENSE LICENSE_AGREEMENT NOTICES
RELEASE_ADDS_WINDOWS: README.md,LICENSE,LICENSE_AGREEMENT,NOTICES
jobs:
build:
name: Build release
runs-on: ${{ matrix.os }}
strategy:
matrix:
target: [ x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin, x86_64-pc-windows-msvc ]
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
arch: amd64
rpmarch: x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
arch: arm64
rpmarch: aarch64
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v3
- name: Update Rust Toolchain Target
run: |
echo "targets = ['${{matrix.target}}']" >> rust-toolchain.toml
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.4.3
- name: Install aarch64-linux gcc
run: sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu -y
if: matrix.target == 'aarch64-unknown-linux-gnu'
- name: Install rpmdevtools
run: sudo apt-get install rpm
if: matrix.os == 'ubuntu-22.04'
- uses: SebRollen/toml-action@v1.0.1
id: version
with:
file: 'Cargo.toml'
field: 'package.version'
- name: Build
uses: actions-rs/cargo@v1
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: 'aarch64-linux-gnu-gcc'
with:
command: build
args: --verbose --release --target ${{ matrix.target }} --features static-link-openssl
if: matrix.os == 'ubuntu-22.04'
# - name: Build
# uses: actions-rs/cargo@v1
# with:
# command: build
# args: --verbose --release --target ${{ matrix.target }}
# if: matrix.os == 'macos-latest'
# - name: Build
# uses: actions-rs/cargo@v1
# with:
# command: build
# args: --verbose --release
# env:
# VCPKGRS_DYNAMIC: 1
# RUSTFLAGS: -Ctarget-feature=+crt-static
# if: matrix.os == 'windows-latest'
# - name: Test
# uses: actions-rs/cargo@v1
# with:
# command: test
# args: --verbose
- name: Create archive for Linux
id: createarchivelinux
run: |
7z a -ttar -so -an ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }} | 7z a -si ${{ env.RELEASE_BIN }}-${{ matrix.target }}.tar.gz
if: matrix.os == 'ubuntu-22.04'
# - name: Install p7zip
# # 7Zip not available on MacOS, install p7zip via homebrew.
# run: brew install p7zip
# if: matrix.os == 'macos-latest'
# - name: Create archive for MacOS
# id: createarchivemacos
# run: |
# 7z a -tzip ${{ env.RELEASE_BIN }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }}
# if: matrix.os == 'macos-latest'
#
# - name: Create archive for Windows
# id: createarchivewindows
# run: |
# choco install 7zip
# 7z a -tzip ${{ env.RELEASE_BIN }}-${{ matrix.target }}.zip ./target/release/${{ env.RELEASE_BIN_WINDOWS }} ${{ env.RELEASE_ADDS }}
# if: matrix.os == 'windows-latest'
# - name: Create Debian package
# id: createdebianpkg
# run: |
# mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}
# mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr
# mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
# mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/DEBIAN
# echo "Package: couchbase-shell
# Version: ${{ steps.version.outputs.value }}
# Maintainer: jack.westwood@couchbase.com
# Architecture: ${{ matrix.arch }}
# Homepage: www.couchbase.sh
# Description: The modern and fun shell for Couchbase Server and Cloud" > ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/DEBIAN/control
# cp {LICENSE,LICENSE_AGREEMENT,NOTICES,README.md} ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
# cp ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
# dpkg --build ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}
# dpkg-deb --info ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
# if: matrix.os == 'ubuntu-22.04'
- name: Create rpm packages
id: createrpmpkgs
run: |
mkdir /home/runner/rpmbuild
mkdir /home/runner/rpmbuild/BUILD
mkdir /home/runner/rpmbuild/RPMS
mkdir /home/runner/rpmbuild/SOURCES
mkdir /home/runner/rpmbuild/SPECS
mkdir /home/runner/rpmbuild/SPRMS
mkdir couchbase-shell-${{ steps.version.outputs.value }}
mkdir couchbase-shell-${{ steps.version.outputs.value }}/usr
mkdir couchbase-shell-${{ steps.version.outputs.value }}/usr/bin
cp ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ./couchbase-shell-${{ steps.version.outputs.value }}/usr/bin/couchbase-shell
cp {LICENSE,LICENSE_AGREEMENT,NOTICES,README.md} ./couchbase-shell-${{ steps.version.outputs.value }}/usr/bin
ls ./couchbase-shell-${{ steps.version.outputs.value }}/usr/bin
tar --create --file couchbase-shell-${{ steps.version.outputs.value }}-${{ matrix.rpmarch }}.tar.gz couchbase-shell-${{ steps.version.outputs.value }}
mv couchbase-shell-${{ steps.version.outputs.value }}-${{ matrix.rpmarch }}.tar.gz /home/runner/rpmbuild/SOURCES
echo "Name: couchbase-shell
Release: 1
Summary: The modern and fun shell for Couchbase Server and Cloud
Source0: %{name}-${{ steps.version.outputs.value }}-%{_arch}.tar.gz
License: Apache Software License 2.0
Version: ${{ steps.version.outputs.value }}
Vendor: Couchbase
%description
The modern and fun shell for Couchbase Server and Cloud
%prep
%setup -q
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p /home/runner/rpmbuild/BUILDROOT/%{_bindir}
cp ./%{_bindir}/* /home/runner/rpmbuild/BUILDROOT/%{_bindir}
%clean
rm -rf $RPM_BUILD_ROOT
%files
%{_bindir}/%{name}
%doc %{_bindir}/README.md
%license %{_bindir}/LICENSE
%{_bindir}/NOTICES
%{_bindir}/LICENSE_AGREEMENT" > /home/runner/rpmbuild/SPECS/couchbase-shell.spec
rpmbuild -bb /home/runner/rpmbuild/SPECS/couchbase-shell.spec --target ${{ matrix.rpmarch }} --define "_bindir /usr/bin"
if: matrix.os == 'ubuntu-22.04'
# - name: Upload Debian artifacts
# uses: actions/upload-artifact@v4
# with:
# name: couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
# path: ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
# if-no-files-found: error
# compression-level: 0
# if: matrix.os == 'ubuntu-22.04'
- name: Upload rpm artifacts
uses: actions/upload-artifact@v4
with:
name: couchbase-shell-${{ steps.version.outputs.value }}-1.${{ matrix.rpmarch }}.rpm
path: ./rpmbuild/RPMS/${{ matrix.rpmarch }}/couchbase-shell-${{ steps.version.outputs.value }}-1.${{ matrix.rpmarch }}.rpm
if-no-files-found: error
compression-level: 0
if: matrix.os == 'ubuntu-22.04'
# - name: Upload artifacts
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.RELEASE_BIN }}-${{ matrix.target }}
# path: ${{ env.RELEASE_BIN }}-${{ matrix.target }}*
# if-no-files-found: error
release:
needs: [ build ]
name: Create release
runs-on: ubuntu-latest
steps:
- name: Create tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ needs.build.outputs.version }}
default_bump: false
create_annotated_tag: true
- name: Download Artifacts
uses: actions/download-artifact@v4.1.7
- name: Add Artifacts to Release
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.RELEASE_BIN }}*/*
*/*.deb
tag_name: v${{ needs.build.outputs.version }}
draft: true
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
name: Release v${{ needs.build.outputs.version }}
fail_on_unmatched_files: true
body: ${{ steps.tag_version.changelog }}