-
Notifications
You must be signed in to change notification settings - Fork 8
97 lines (94 loc) · 3.54 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
name: Release
on:
push:
tags:
- v*
jobs:
build-binaries:
runs-on: "${{ matrix.os }}"
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: macOS-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl
run: sudo apt-get install musl-tools
if: contains(matrix.target, 'linux-musl')
- run: cargo build --release --target ${{ matrix.target }}
- run: strip 'target/${{ matrix.target }}/release/git-gone'
if: ${{ !contains(matrix.target, 'windows') }}
- id: version
shell: bash
run: |
VERSION="$(cargo pkgid | cut -d'#' -f2 | cut -d: -f2)"
echo "::set-output name=version::$VERSION"
echo "::set-output name=tag::v$VERSION"
- id: package
shell: bash
run: |
ARCHIVE_NAME="git-gone-${{ steps.version.outputs.tag }}-${{ matrix.target }}"
if [[ '${{ matrix.target }}' == *windows* ]]; then
ARCHIVE_FILE="${ARCHIVE_NAME}.zip"
mv LICENSE LICENSE.txt
7z a "${ARCHIVE_FILE}" "./target/${{ matrix.target }}/release/git-gone.exe" ./git-gone.1.adoc ./CHANGELOG.md ./LICENSE.txt
echo ::set-output "name=file::${ARCHIVE_FILE}"
echo ::set-output "name=name::${ARCHIVE_NAME}.zip"
else
ARCHIVE_FILE="${ARCHIVE_NAME}.tar.gz"
mkdir "/tmp/${ARCHIVE_NAME}"
cp git-gone.1.adoc git-gone.1 CHANGELOG.md LICENSE "target/${{ matrix.target }}/release/git-gone" "/tmp/${ARCHIVE_NAME}"
tar -czf "${PWD}/${ARCHIVE_FILE}" -C /tmp/ "${ARCHIVE_NAME}"
echo ::set-output "name=file::${ARCHIVE_FILE}"
echo ::set-output "name=name::${ARCHIVE_NAME}.tar.gz"
fi
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.name }}
path: ${{ steps.package.outputs.file }}
create-release:
runs-on: ubuntu-latest
needs: build-binaries
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./binaries
- shell: bash
run: |
for directory in *; do (
cd "$directory"; shopt -s nullglob; b2sum *.zip *.tar.gz >> ../B2SUMS.txt; sha512sum *.zip *.tar.gz >> ../SHA512SUM.txt
); done
working-directory: binaries
- id: version
shell: bash
run: |
VERSION="$(cargo pkgid | cut -d'#' -f2 | cut -d: -f2)"
echo "::set-output name=version::$VERSION"
- shell: bash
run: |
awk -v r='${{ steps.version.outputs.version }}' \
'/^\[[^]]*\]/{print $0}/^## \[[0-9]/ && match($0, /\[[0-9][^]]*\]/){if (r == substr($0, RSTART+1, RLENGTH-2)) { p=1; next } else { p=0 } }p' \
CHANGELOG.md > ./CHANGELOG-release.md
cat CHANGELOG-release.md
- uses: softprops/action-gh-release@v2
with:
name: v${{ steps.version.outputs.version }}
body_path: ./CHANGELOG-release.md
files: |
./binaries/**/*.zip
./binaries/**/*.tar.gz
./binaries/B2SUMS.txt
./binaries/SHA512SUM.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}