]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/.github/workflows/upload-assets.yml
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / src / tools / rustfmt / .github / workflows / upload-assets.yml
1 name: upload
2
3 on:
4   push:
5   release:
6     types: [created]
7   workflow_dispatch:
8
9 jobs:
10   build-release:
11     name: build-release
12     strategy:
13       matrix:
14         build: [linux-x86_64, macos-x86_64, windows-x86_64-gnu, windows-x86_64-msvc]
15         include:
16           - build: linux-x86_64
17             os: ubuntu-latest
18             rust: nightly
19             target: x86_64-unknown-linux-gnu
20           - build: macos-x86_64
21             os: macos-latest
22             rust: nightly
23             target: x86_64-apple-darwin
24           - build: windows-x86_64-gnu
25             os: windows-latest
26             rust: nightly-x86_64-gnu
27             target: x86_64-pc-windows-gnu
28           - build: windows-x86_64-msvc
29             os: windows-latest
30             rust: nightly-x86_64-msvc
31             target: x86_64-pc-windows-msvc
32     runs-on: ${{ matrix.os }}
33     steps:
34       - uses: actions/checkout@v3
35
36         # Run build
37       - name: install rustup
38         run: |
39           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
40           sh rustup-init.sh -y --default-toolchain none
41           rustup target add ${{ matrix.target }}
42
43       - name: Add mingw64 to path for x86_64-gnu
44         run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
45         if: matrix.rust == 'nightly-x86_64-gnu'
46         shell: bash
47
48       - name: Build release binaries
49         uses: actions-rs/cargo@v1
50         with:
51           command: build
52           args: --release
53
54       - name: Build archive
55         shell: bash
56         run: |
57           staging="rustfmt_${{ matrix.build }}_${{ github.event.release.tag_name }}"
58           mkdir -p "$staging"
59
60           cp {README.md,Configurations.md,CHANGELOG.md,LICENSE-MIT,LICENSE-APACHE} "$staging/"
61
62           if [ "${{ matrix.os }}" = "windows-latest" ]; then
63             cp target/release/{rustfmt.exe,cargo-fmt.exe,rustfmt-format-diff.exe,git-rustfmt.exe} "$staging/"
64             7z a "$staging.zip" "$staging"
65             echo "ASSET=$staging.zip" >> $GITHUB_ENV
66           else
67             cp target/release/{rustfmt,cargo-fmt,rustfmt-format-diff,git-rustfmt} "$staging/"
68             tar czf "$staging.tar.gz" "$staging"
69             echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
70           fi
71
72       - name: Upload Release Asset
73         if: github.event_name == 'release'
74         uses: actions/upload-release-asset@v1
75         env:
76           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77         with:
78           upload_url: ${{ github.event.release.upload_url }}
79           asset_path: ${{ env.ASSET }}
80           asset_name: ${{ env.ASSET }}
81           asset_content_type: application/octet-stream