forked from orhun/git-cliff
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (163 loc) · 6.06 KB
/
cd.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
jobs:
generate-changelog:
name: Generate changelog
runs-on: ubuntu-20.04
outputs:
release_body: ${{ steps.release.outputs.release_body }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v1
id: git-cliff
with:
config: config/cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGES.md
- name: Set the release body
id: release
shell: bash
run: |
r=$(cat ${{ steps.git-cliff.outputs.changelog }})
r="$(printf "$r" | tail -n +3)"
r="${r//'%'/'%25'}"
r="${r//$'\n'/'%0A'}"
r="${r//$'\r'/'%0D'}"
echo "::set-output name=release_body::$r"
publish-github:
name: Publish on GitHub
needs: generate-changelog
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux-gnu, linux-musl, win-gnu, win-msvc, win32-msvc, macos]
include:
- BUILD: linux-gnu
OS: ubuntu-20.04
TOOLCHAIN: stable
TARGET: x86_64-unknown-linux-gnu
- BUILD: linux-musl
OS: ubuntu-20.04
TOOLCHAIN: stable
TARGET: x86_64-unknown-linux-musl
- BUILD: win-gnu
OS: windows-2019
TOOLCHAIN: stable
TARGET: x86_64-pc-windows-gnu
- BUILD: win-msvc
OS: windows-2019
TOOLCHAIN: stable
TARGET: x86_64-pc-windows-msvc
- BUILD: win32-msvc
OS: windows-2019
TOOLCHAIN: stable
TARGET: i686-pc-windows-msvc
- BUILD: macos
OS: macos-11
TOOLCHAIN: stable
TARGET: x86_64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- 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
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.TOOLCHAIN }}
target: ${{ matrix.TARGET }}
override: true
- name: Build
run: cargo build --release --locked --target ${{ matrix.TARGET }}
- name: Prepare release assets
shell: bash
run: |
mkdir -p release/{man,completions}
cp {LICENSE,README.md,CHANGELOG.md} release/
OUT_DIR=release/completions/ cargo run --release --bin git-cliff-completions
OUT_DIR=release/man/ cargo run --release --bin git-cliff-mangen
if [ "${{ matrix.OS }}" = "windows-2019" ]; then
cp target/${{ matrix.TARGET }}/release/git-cliff.exe release/
else
cp target/${{ matrix.TARGET }}/release/git-cliff release/
fi
mv release/ git-cliff-${{ env.RELEASE_VERSION }}/
- name: Create release artifacts
shell: bash
run: |
if [ "${{ matrix.OS }}" = "windows-2019" ]; then
7z a -tzip "git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.zip" \
git-cliff-${{ env.RELEASE_VERSION }}/
else
tar -czvf git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
git-cliff-${{ env.RELEASE_VERSION }}/
shasum -a 512 git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
> git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz.sha512
fi
- name: Sign the release
if: matrix.OS == 'ubuntu-20.04' || matrix.OS == 'macos-11'
run: |
echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --import private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --detach-sign \
git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz
- name: Upload the release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
release_name: "Release v${{ env.RELEASE_VERSION }}"
body: "${{ needs.generate-changelog.outputs.release_body }}"
publish-crates-io:
name: Publish on crates.io
needs: publish-github
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set the release version
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
override: true
- name: Prepare for the crates.io release
run: |
mkdir git-cliff-core/config/
cp config/cliff.toml git-cliff-core/config/
sed -i 's|"../config/"|"config/"|' git-cliff-core/src/embed.rs
- name: Publish the library
run: |
cargo publish --allow-dirty --manifest-path git-cliff-core/Cargo.toml \
--locked --token ${{ secrets.CARGO_TOKEN }}
- name: Wait for library to update
shell: bash
run: |
crate_status="https://raw.githubusercontent.com/rust-lang/crates.io-index/master/gi/t-/git-cliff-core"
until curl -s "$crate_status" | grep -q '"vers":"${{ env.RELEASE_VERSION }}"'; do sleep 5; done;
- name: Publish the binary
run: |
cargo publish --allow-dirty --manifest-path git-cliff/Cargo.toml \
--locked --token ${{ secrets.CARGO_TOKEN }}