-
-
Notifications
You must be signed in to change notification settings - Fork 7
136 lines (118 loc) · 3.89 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
name: Release
on:
push:
tags:
- "v*"
env:
APP_NAME: bilal
jobs:
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# it is a must!
fetch-depth: 0
- name: Set the release version
shell: bash
run: |
echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
echo ${{ env.RELEASE_VERSION }}
- name: Checkout current tag
shell: bash
run: |
git checkout v${{ env.RELEASE_VERSION }}
- name: Generate a changelog
uses: orhun/git-cliff-action@v3
id: git-cliff
with:
config: configs/cliff.toml
args: -vv --strip header --current
env:
OUTPUT: CHANGELOG.md.tmp
- name: Print the changelog
run: cat "${{ steps.git-cliff.outputs.changelog }}"
- name: Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GH_TOKEN }}
name: "v${{ env.RELEASE_VERSION }}"
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
generate_release_notes: true
body_path: "${{ steps.git-cliff.outputs.changelog }}"
publish:
name: Publish
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {
build: linux-gnu,
os: ubuntu-22.04,
target: x86_64-unknown-linux-gnu,
}
- {
build: linux-musl,
os: ubuntu-22.04,
target: x86_64-unknown-linux-musl,
}
- { build: win-gnu, os: windows-2022, target: x86_64-pc-windows-gnu }
- {
build: win-msvc,
os: windows-2022,
target: x86_64-pc-windows-msvc,
}
- {
build: win32-msvc,
os: windows-2022,
target: i686-pc-windows-msvc,
}
- { build: macos, os: macos-14, target: x86_64-apple-darwin }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set the release version
shell: bash
run: |
echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
echo ${{ env.RELEASE_VERSION }}
- name: Install musl-tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
--allow-unauthenticated musl-tools
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
outdir="./target/release"
staging="${{ env.APP_NAME }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
mkdir -p "$staging"/doc
cp -r {README.md,LICENSE*} "$staging/"
cp -r {CHANGELOG.md,docs/*} "$staging/doc/"
if [[ "${{ matrix.os }}" =~ ^windows-.*$ ]]; then
cp "target/${{ matrix.target }}/release/${{ env.APP_NAME }}.exe" "$staging/"
cd "$staging"
7z a "../$staging.zip" .
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp "target/${{ matrix.target }}/release/${{ env.APP_NAME }}" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GH_TOKEN }}
name: "v${{ env.RELEASE_VERSION }}"
files: ${{ env.ASSET }}
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
generate_release_notes: false