-
Notifications
You must be signed in to change notification settings - Fork 3
153 lines (145 loc) · 4.71 KB
/
CD.yaml
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
# SPDX-FileCopyrightText: 2022 Shun Sakai
#
# SPDX-License-Identifier: GPL-3.0-or-later
name: CD
on:
pull_request:
push:
branches:
- "develop"
tags:
- "abcrypt-cli-v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
env:
CARGO_PROFILE_RELEASE_LTO: true
CARGO_PROFILE_RELEASE_PANIC: "abort"
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
outputs:
extracted_version: ${{ steps.extracted_version.outputs.version }}
strategy:
matrix:
target:
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl
- aarch64-apple-darwin
- x86_64-apple-darwin
- aarch64-pc-windows-msvc
- x86_64-pc-windows-msvc
include:
- target: aarch64-unknown-linux-musl
os: ubuntu-22.04
use-cross: true
- target: x86_64-unknown-linux-musl
os: ubuntu-22.04
use-cross: true
- target: aarch64-apple-darwin
os: macos-12
- target: x86_64-apple-darwin
os: macos-12
- target: aarch64-pc-windows-msvc
os: windows-2022
- target: x86_64-pc-windows-msvc
os: windows-2022
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install cross
if: ${{ matrix.use-cross }}
uses: taiki-e/[email protected]
with:
tool: cross
- name: Cache build artifacts
uses: Swatinem/[email protected]
with:
key: ${{ matrix.target }}
- name: Setup Ruby
if: matrix.os != 'windows-2022' && !matrix.use-cross
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install Asciidoctor
if: matrix.os != 'windows-2022' && !matrix.use-cross
run: |
gem install asciidoctor
asciidoctor -V
- name: Build a package
if: ${{ !matrix.use-cross }}
run: cargo build -p abcrypt-cli --release --target ${{ matrix.target }}
- name: Build a package with cross
if: ${{ matrix.use-cross }}
run: cross build -p abcrypt-cli --release --target ${{ matrix.target }}
- name: Get version
id: get_version
uses: battila7/[email protected]
- name: Extract version
id: extracted_version
shell: bash
run: |
version="${{ steps.get_version.outputs.version }}"
if [[ "${version}" =~ ^abcrypt-cli-v.* ]] ; then
version="${version##*-}"
fi
echo "version=${version}" >> "$GITHUB_OUTPUT"
- name: Create a package
shell: bash
run: |
if [ "${{ matrix.os }}" != "windows-2022" ] ; then
bin="target/${{ matrix.target }}/release/abcrypt"
else
bin="target/${{ matrix.target }}/release/abcrypt.exe"
fi
package="abcrypt-${{ steps.extracted_version.outputs.version }}-${{ matrix.target }}"
mkdir -p "${package}"/docs
cp crates/cli/README.md "${bin}" "${package}"
cp -r LICENSES "${package}"
cp crates/cli/{AUTHORS,BUILD,CHANGELOG,CONTRIBUTING}.adoc "${package}"/docs
if [ "${{ matrix.os }}" != "windows-2022" ] ; then
mkdir -p "${package}"/man
cp "$(find ./target -path '*/abcrypt-cli-*/out' -type d)"/* "${package}"/man
fi
if [ "${{ matrix.os }}" != "windows-2022" ] ; then
tar -cvf "${package}.tar" "${package}"
zstd --rm -19 -v "${package}.tar"
else
7z a -bb -mx=9 -m0=LZMA "${package}.7z" "${package}"
fi
rm -rv abcrypt-*/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: "abcrypt-${{ steps.extracted_version.outputs.version }}-${{ matrix.target }}"
path: "abcrypt-*.*"
release:
name: Release
needs: build
runs-on: ubuntu-22.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4
- name: Calculate checksums
run: |
mv abcrypt-*/* .
rmdir -v abcrypt-*/
sha256sum abcrypt-* | tee sha256sums.txt
b2sum abcrypt-* | tee b2sums.txt
- name: Release
uses: softprops/[email protected]
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
abcrypt-*
sha256sums.txt
b2sums.txt
name: "Release abcrypt-cli ${{ needs.build.outputs.extracted_version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}