-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (88 loc) · 3.05 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
name: release
on:
push:
tags:
- '*'
jobs:
build-package:
name: build-package
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- linux
include:
- build: linux
os: ubuntu-22.04
target: x86_64-unknown-linux-musl
binary_ext:
env:
# Backtraces for panics.
RUST_BACKTRACE: 1
TARGET_FLAGS:
TARGET_DIR: ./target
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare environment
shell: bash
run: |
printf 'TARGET_FLAGS=--target %s\n' "${{ matrix.target }}" >> $GITHUB_ENV
printf 'TARGET_DIR=./target/${{ matrix.target }}\n' >> $GITHUB_ENV
printf 'RELEASE_VERSION=%s\n' "${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
printf 'RELEASE_BINARY=%s\n' "target/${{ matrix.target }}/release/commitmsgfmt${{ matrix.binary_ext }}" >> $GITHUB_ENV
# So much cruft just to install Asciidoctor.
# It's possible to do something like
# run: ./ci/install-${{ matrix.os }}
# but I couldn't get Windows to do anything that way.
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends \
asciidoctor
- name: Install dependencies (Windows)
if: matrix.os == 'windows-2022'
run: gem install asciidoctor
- name: Install dependencies (macOS)
if: matrix.os == 'macos-12'
run: brew install asciidoctor
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
# Build all releases on nightly for latest optimizations.
toolchain: nightly
targets: ${{ matrix.target }}
- name: Install Cross
run: cargo install cross
- name: Build release
run: cross build --verbose ${{ env.TARGET_FLAGS }}
- name: Strip release binary
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "${{ env.RELEASE_BINARY }}"
- name: Assemble package
shell: bash
run: |
package="commitmsgfmt-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
mkdir -p "$package"
asciidoctor --doctype manpage --backend manpage "doc/*.adoc"
cp "doc/commitmsgfmt.1" "$package"
cp LICENSE.txt "$package"
cp README.md "$package"
cp CHANGELOG.md "$package"
cp -r contrib "$package"
cp "${{ env.RELEASE_BINARY }}" "$package"
if [[ "${{ matrix.os }}" = 'windows-2022' ]]
then
7z a "$package.zip" "$package"
printf 'ASSET=%s\n' "$package.zip" >> $GITHUB_ENV
else
tar caf "$package.tar.gz" "$package"
printf 'ASSET=%s\n' "$package.tar.gz" >> $GITHUB_ENV
fi
- name: Upload package
uses: softprops/action-gh-release@v1
with:
draft: true
tag_name: ${{ env.RELEASE_VERSION }}
files: ${{ env.ASSET }}