This repository has been archived by the owner on Mar 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
101 lines (98 loc) · 3.42 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
name: Release
on:
push:
tags:
- mdcat-*
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@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}
- uses: actions/setup-ruby@v1
- name: install asciidoctor for manpage build
run: gem install asciidoctor
- name: Install musl
run: sudo apt-get install musl-tools
if: contains(matrix.target, 'linux-musl')
- name: Build in release configuration
shell: bash
id: build
run: |
OUTDIR="$(cargo build --locked --target '${{ matrix.target }}' --release --message-format=json-render-diagnostics |
jq -r 'select(.out_dir) | select(.package_id | startswith("mdcat ")) | .out_dir')"
echo "::set-output name=outdir::$OUTDIR"
- name: Strip binary
run: strip 'target/${{ matrix.target }}/release/mdcat'
if: "!contains(matrix.target, 'windows')"
- name: Get version
id: version
shell: bash
run: |
VERSION="$(cargo pkgid | cut -d'#' -f2 | cut -d: -f2)"
echo "::set-output name=version::$VERSION"
- name: Build package
id: package
shell: bash
run: ./scripts/package '${{ steps.version.outputs.version }}' '${{ matrix.target }}' '${{ steps.build.outputs.outdir }}'
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package.outputs.name }}
path: ${{ steps.package.outputs.file }}
create-release:
runs-on: ubuntu-latest
needs: build-binaries
steps:
- uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: ./artifacts
- name: Aggregate assets
run: |
mkdir ./assets
mv ./artifacts/*/*.{zip,tar.gz} ./assets
- name: Compute checksums
# We create checksum files in the parent directory to avoid checksumming the checksums
run: |
b2sum * > ../B2SUMS.txt
sha512sum * > ../SHA512SUM.txt
mv ../B2SUMS.txt ../SHA512SUM.txt .
working-directory: assets
- name: Get version
id: version
shell: bash
run: |
VERSION="$(cargo pkgid | cut -d'#' -f2 | cut -d: -f2)"
echo "::set-output name=version::$VERSION"
- name: Extract changelog
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
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: mdcat-${{ steps.version.outputs.version }}
body_path: ./CHANGELOG-release.md
files: "./assets/*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}