|
1 | | -name: Build and Release |
| 1 | +name: Publish |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - "*" |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - build: |
10 | | - name: Build ${{ matrix.binary_target }} |
| 9 | + publish: |
| 10 | + name: Publish for ${{ matrix.os }} |
11 | 11 | runs-on: ${{ matrix.os }} |
12 | | - env: |
13 | | - BINARY_NAME: rust_github_action |
14 | 12 | strategy: |
15 | | - fail-fast: false |
16 | 13 | matrix: |
17 | 14 | include: |
18 | 15 | - os: ubuntu-latest |
19 | | - binary_target: x86_64-unknown-linux-musl |
20 | | - - os: ubuntu-latest |
21 | | - binary_target: x86_64-unknown-linux-gnu |
22 | | - - os: ubuntu-latest |
23 | | - binary_target: aarch64-unknown-linux-gnu |
24 | | - - os: ubuntu-latest |
25 | | - binary_target: armv7-unknown-linux-gnueabihf |
| 16 | + artifact_name: rust_github_action |
| 17 | + asset_name: rust_github_action-linux-amd64 |
26 | 18 | - os: windows-latest |
27 | | - binary_target: x86_64-pc-windows-msvc |
| 19 | + artifact_name: rust_github_action.exe |
| 20 | + asset_name: rust_github_action-windows-amd64 |
28 | 21 | - os: macos-latest |
29 | | - binary_target: x86_64-apple-darwin |
30 | | - - os: macos-latest |
31 | | - binary_target: aarch64-apple-darwin |
| 22 | + artifact_name: rust_github_action |
| 23 | + asset_name: rust_github_action-macos-amd64 |
32 | 24 |
|
33 | 25 | steps: |
34 | | - - name: Checkout repository |
35 | | - uses: actions/checkout@v4 |
36 | | - |
37 | | - - name: Install musl tools |
38 | | - if: matrix.binary_target == 'x86_64-unknown-linux-musl' |
39 | | - run: sudo apt-get install -y musl-tools |
40 | | - |
41 | | - - name: Install ARM cross-compilation tools |
42 | | - if: |
43 | | - matrix.binary_target == 'aarch64-unknown-linux-gnu' || |
44 | | - matrix.binary_target == 'armv7-unknown-linux-gnueabihf' |
45 | | - run: | |
46 | | - sudo apt-get update |
47 | | - if [[ "${{ matrix.binary_target }}" == "aarch64-unknown-linux-gnu" ]]; then |
48 | | - sudo apt-get install -y gcc-aarch64-linux-gnu |
49 | | - elif [[ "${{ matrix.binary_target }}" == "armv7-unknown-linux-gnueabihf" ]]; then |
50 | | - sudo apt-get install -y gcc-arm-linux-gnueabihf |
51 | | - fi |
52 | | -
|
53 | | - - name: Install target |
54 | | - run: rustup target add ${{ matrix.binary_target }} |
55 | | - |
56 | | - - name: Build binary |
57 | | - run: cargo build --release --target ${{ matrix.binary_target }} |
58 | | - |
59 | | - - name: Set archive name |
60 | | - id: archive |
61 | | - shell: bash |
62 | | - run: | |
63 | | - if [[ "${{ matrix.os }}" == "windows-latest" ]]; then |
64 | | - echo "ARCHIVE_NAME=${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.binary_target }}.zip" >> $GITHUB_ENV |
65 | | - else |
66 | | - echo "ARCHIVE_NAME=${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.binary_target }}.tar.gz" >> $GITHUB_ENV |
67 | | - fi |
68 | | -
|
69 | | - - name: Prepare binary (Unix) |
70 | | - if: matrix.os != 'windows-latest' |
71 | | - run: | |
72 | | - cd target/${{ matrix.binary_target }}/release |
73 | | - tar -czf ../../../${{ env.ARCHIVE_NAME }} ${{ env.BINARY_NAME }} |
74 | | - cd - |
75 | | -
|
76 | | - - name: Prepare binary (Windows) |
77 | | - if: matrix.os == 'windows-latest' |
78 | | - shell: pwsh |
79 | | - run: | |
80 | | - cd target/${{ matrix.binary_target }}/release |
81 | | - $BINARY_NAME = "${{ env.BINARY_NAME }}.exe" |
82 | | - Compress-Archive -Path $BINARY_NAME -DestinationPath ../../../${{ env.ARCHIVE_NAME }} |
83 | | - cd - |
84 | | -
|
85 | | - - name: Upload Release Asset |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + - name: Build |
| 28 | + run: cargo build --release --locked |
| 29 | + - name: Upload binaries to release |
86 | 30 | uses: svenstaro/upload-release-action@v2 |
87 | 31 | with: |
88 | 32 | repo_token: ${{ secrets.GITHUB_TOKEN }} |
89 | | - file: ${{ env.ARCHIVE_NAME }} |
| 33 | + file: target/release/${{ matrix.artifact_name }} |
| 34 | + asset_name: ${{ matrix.asset_name }} |
90 | 35 | tag: ${{ github.ref }} |
91 | | - overwrite: true |
0 commit comments