|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build - ${{ matrix.target }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - os: ubuntu-latest |
| 19 | + target: x86_64-unknown-linux-gnu |
| 20 | + asset_name: rustenv-linux-x64 |
| 21 | + use_cross: false |
| 22 | + - os: ubuntu-latest |
| 23 | + target: aarch64-unknown-linux-gnu |
| 24 | + asset_name: rustenv-linux-arm64 |
| 25 | + use_cross: true |
| 26 | + - os: macos-latest |
| 27 | + target: x86_64-apple-darwin |
| 28 | + asset_name: rustenv-darwin-x64 |
| 29 | + use_cross: false |
| 30 | + - os: macos-latest |
| 31 | + target: aarch64-apple-darwin |
| 32 | + asset_name: rustenv-darwin-arm64 |
| 33 | + use_cross: false |
| 34 | + - os: windows-latest |
| 35 | + target: x86_64-pc-windows-msvc |
| 36 | + asset_name: rustenv-win32-x64.exe |
| 37 | + use_cross: false |
| 38 | + |
| 39 | + steps: |
| 40 | + - name: Checkout repository |
| 41 | + uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Install Rust toolchain |
| 44 | + uses: dtolnay/rust-toolchain@stable |
| 45 | + with: |
| 46 | + targets: ${{ matrix.target }} |
| 47 | + |
| 48 | + - name: Install Cross (if required) |
| 49 | + if: matrix.use_cross |
| 50 | + run: cargo install cross --git https://github.com/cross-rs/cross |
| 51 | + |
| 52 | + - name: Build binary (Standard) |
| 53 | + if: ${{ !matrix.use_cross }} |
| 54 | + run: cargo build --target ${{ matrix.target }} --release |
| 55 | + |
| 56 | + - name: Build binary (Cross) |
| 57 | + if: matrix.use_cross |
| 58 | + run: cross build --target ${{ matrix.target }} --release |
| 59 | + |
| 60 | + - name: Prepare asset (Windows) |
| 61 | + if: matrix.os == 'windows-latest' |
| 62 | + run: | |
| 63 | + mv target\${{ matrix.target }}\release\rustenv.exe ${{ matrix.asset_name }} |
| 64 | +
|
| 65 | + - name: Prepare asset (Unix) |
| 66 | + if: matrix.os != 'windows-latest' |
| 67 | + run: | |
| 68 | + mv target/${{ matrix.target }}/release/rustenv ${{ matrix.asset_name }} |
| 69 | +
|
| 70 | + - name: Upload Artifact |
| 71 | + uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: ${{ matrix.asset_name }} |
| 74 | + path: ${{ matrix.asset_name }} |
| 75 | + |
| 76 | + release: |
| 77 | + name: Create GitHub Release |
| 78 | + needs: build |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - name: Checkout repository |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Download all build artifacts |
| 85 | + uses: actions/download-artifact@v4 |
| 86 | + with: |
| 87 | + path: ./artifacts |
| 88 | + |
| 89 | + - name: Flatten artifacts directory |
| 90 | + run: | |
| 91 | + mkdir dist |
| 92 | + find ./artifacts -type f -exec cp {} ./dist/ \; |
| 93 | + ls -la ./dist/ |
| 94 | +
|
| 95 | + - name: Create Release and Upload Assets |
| 96 | + uses: softprops/action-gh-release@v1 |
| 97 | + with: |
| 98 | + files: | |
| 99 | + dist/rustenv-linux-x64 |
| 100 | + dist/rustenv-linux-arm64 |
| 101 | + dist/rustenv-darwin-x64 |
| 102 | + dist/rustenv-darwin-arm64 |
| 103 | + dist/rustenv-win32-x64.exe |
| 104 | + env: |
| 105 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments