]> git.lizzy.rs Git - rust.git/blob - .github/workflows/upload-assets.yml
ci: update GHA workflows
[rust.git] / .github / workflows / upload-assets.yml
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: install
41           args: --force cargo-make
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 "ASSET=$staging.zip" >> $GITHUB_ENV
61           else
62             cp target/release/{rustfmt,cargo-fmt,rustfmt-format-diff,git-rustfmt} "$staging/"
63             tar czf "$staging.tar.gz" "$staging"
64             echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
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