-
-
Notifications
You must be signed in to change notification settings - Fork 5
121 lines (109 loc) · 3.65 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
name: upload
# copied from https://github.com/rust-lang/rustfmt/blob/master/.github/workflows/upload-assets.yml
on:
release:
types: [created]
workflow_dispatch:
jobs:
build-release:
name: build-release
strategy:
matrix:
build:
[
linux-x86_64,
linux-x86_64-musl,
macos-x86_64,
windows-x86_64-gnu,
windows-x86_64-msvc,
]
include:
- build: linux-x86_64
os: ubuntu-latest
rust: nightly
target: x86_64-unknown-linux-gnu
build_command: build
- build: linux-x86_64-musl
os: ubuntu-latest
rust: nightly
target: x86_64-unknown-linux-musl
build_command: zigbuild
- build: macos-x86_64
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
build_command: build
- build: windows-x86_64-gnu
os: windows-latest
rust: nightly-x86_64-gnu
target: x86_64-pc-windows-gnu
build_command: build
- build: windows-x86_64-msvc
os: windows-latest
rust: nightly-x86_64-msvc
target: x86_64-pc-windows-msvc
build_command: build
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
# Run build
- name: install rustup
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
rustup target add ${{ matrix.target }}
- name: Add mingw64 to path for x86_64-gnu
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
if: matrix.rust == 'nightly-x86_64-gnu'
shell: bash
- name: Install dependencies for x86_64-musl
run: |
sudo apt install musl-tools python3-pip
sudo pip3 install ziglang
cargo install cargo-zigbuild
if: matrix.target == 'x86_64-unknown-linux-musl'
shell: bash
- name: Build release binaries
uses: actions-rs/cargo@v1
with:
command: ${{ matrix.build_command }}
args: --release --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
staging="cbfmt_${{ matrix.build }}_${{ github.event.release.tag_name }}"
mkdir -p "$staging"
cp {README.md,LICENSE.md} "$staging/"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp target/${{ matrix.target }}/release/cbfmt.exe "$staging/"
7z a "$staging.zip" "$staging"
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp target/${{ matrix.target }}/release/cbfmt "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload Release Asset
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
publish-to-cargo:
name: Publishing to Cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty