Skip to content

Commit a8a73f5

Browse files
authored
Add upload-assets.yml (#4280)
1 parent ccf3ebf commit a8a73f5

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

.github/workflows/upload-assets.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: upload
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build-release:
9+
name: build-release
10+
strategy:
11+
matrix:
12+
build: [linux, macos, windows-gnu, windows-msvc]
13+
include:
14+
- build: linux
15+
os: ubuntu-latest
16+
rust: nightly
17+
- build: macos
18+
os: macos-latest
19+
rust: nightly
20+
- build: windows-gnu
21+
os: windows-latest
22+
rust: nightly-x86_64-gnu
23+
- build: windows-msvc
24+
os: windows-latest
25+
rust: nightly-x86_64-msvc
26+
runs-on: ${{ matrix.os }}
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
- name: Install Rust
31+
uses: actions-rs/toolchain@v1
32+
with:
33+
profile: minimal
34+
toolchain: ${{ matrix.rust }}
35+
override: true
36+
37+
- name: Install cargo-make
38+
uses: actions-rs/cargo@v1
39+
with:
40+
command: build
41+
args: --release
42+
43+
- name: Build release binaries
44+
uses: actions-rs/cargo@v1
45+
with:
46+
command: make
47+
args: release
48+
49+
- name: Build archive
50+
shell: bash
51+
run: |
52+
staging="rustfmt_${{ matrix.build }}_${{ github.event.release.tag_name }}"
53+
mkdir -p "$staging"
54+
55+
cp {README.md,Configurations.md,CHANGELOG.md,LICENSE-MIT,LICENSE-APACHE} "$staging/"
56+
57+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
58+
cp "target/release/{rustfmt.exe,cargo-fmt.exe,rustfmt-format-diff.exe,git-rustfmt.exe}" "$staging/"
59+
7z a "$staging.zip" "$staging"
60+
echo "::set-env name=ASSET::$staging.zip"
61+
else
62+
cp "target/release/{rustfmt,cargo-fmt,rustfmt-format-diff,git-rustfmt} "$staging/"
63+
tar czf "$staging.tar.gz" "$staging"
64+
echo "::set-env name=ASSET::$staging.tar.gz"
65+
fi
66+
67+
- name: Upload Release Asset
68+
uses: actions/upload-release-asset@v1
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
upload_url: ${{ github.event.release.upload_url }}
73+
asset_path: ${{ env.ASSET }}
74+
asset_name: ${{ env.ASSET }}
75+
asset_content_type: application/octet-stream

Makefile.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ args = [
3232
"--features=rustfmt,cargo-fmt" # Install only rustfmt and cargo-fmt
3333
]
3434

35+
[tasks.release]
36+
command = "cargo"
37+
args = [
38+
"build",
39+
"--all-features",
40+
"--release",
41+
]
42+
3543
[tasks.test-all]
3644
dependencies = ["build-bin"]
3745
run_task = { name = ["test", "test-ignored"] }

0 commit comments

Comments
 (0)