-
-
Notifications
You must be signed in to change notification settings - Fork 8
165 lines (146 loc) Β· 5.15 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
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
# Copyright (c) 2023 Catppuccin
# Copyright (c) 2015 Andrew Gallant
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
name: build-and-release
on:
workflow_dispatch:
push:
branches:
- main
env:
BINARY: mdbook-catppuccin
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
build:
needs: ["release-please"]
if: needs.release-please.outputs.release_created
runs-on: ${{ matrix.os }}
env:
CARGO: cargo
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
TARGET_FLAGS:
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
build:
- linux-musl
- linux-gnu
- linux-arm
- macos
- win-msvc
- win-gnu
- win32-msvc
include:
- build: linux-musl
os: ubuntu-22.04
rust: nightly
target: x86_64-unknown-linux-musl
- build: linux-gnu
os: ubuntu-22.04
rust: nightly
target: x86_64-unknown-linux-gnu
- build: linux-arm
os: ubuntu-22.04
rust: nightly
target: arm-unknown-linux-gnueabihf
- build: macos
os: macos-12
rust: nightly
target: x86_64-apple-darwin
- build: win-msvc
os: windows-2022
rust: nightly
target: x86_64-pc-windows-msvc
- build: win-gnu
os: windows-2022
rust: nightly-x86_64-gnu
target: x86_64-pc-windows-gnu
- build: win32-msvc
os: windows-2022
rust: nightly
target: i686-pc-windows-msvc
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Packages (Ubuntu)
if: matrix.os == 'ubuntu-22.04'
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends musl-tools
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.rust }}
- name: Use Cross
if: matrix.os != 'windows-2022'
run: |
cargo install cross --git https://github.com/cross-rs/cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Show Cargo Command
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET_FLAGS }}"
echo "target dir is: ${{ env.TARGET_DIR }}"
- name: Compile
run: ${{ env.CARGO }} build --release --verbose ${{ env.TARGET_FLAGS }}
- name: Strip Binary (linux and macos)
if: matrix.build == 'linux-musl' || matrix.build == 'linux-gnu' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/${{ env.BINARY }}"
- name: Strip Binary (linux-arm)
if: matrix.build == 'linux-arm'
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
rustembedded/cross:arm-unknown-linux-gnueabihf \
arm-linux-gnueabihf-strip \
/target/arm-unknown-linux-gnueabihf/release/${{ env.BINARY }}
- name: Create Artifact
id: create-artifact
run: |
staging="${{ env.BINARY }}-${{ matrix.target }}"
mkdir "$staging"
cp LICENSE "$staging/"
if [ "${{ matrix.os }}" == "windows-2022" ]; then
artifact="${{ env.TARGET_DIR }}/release/${{ env.BINARY }}.exe"
cp "$artifact" "$staging/"
7z a "$staging.zip" "$staging"
echo "asset=$staging.zip" >> $GITHUB_OUTPUT
else
artifact="${{ env.TARGET_DIR}}/release/${{ env.BINARY }}"
cp "$artifact" "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "asset=$staging.tar.gz" >> $GITHUB_OUTPUT
fi
- name: Upload Artifacts to Release
run: gh release upload ${{ needs.release-please.outputs.tag_name }} ${{ steps.create-artifact.outputs.asset }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}