|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Build ${{ matrix.target }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - target: x86_64-unknown-linux-gnu |
| 20 | + os: ubuntu-latest |
| 21 | + - target: aarch64-unknown-linux-gnu |
| 22 | + os: ubuntu-latest |
| 23 | + use-cross: true |
| 24 | + - target: x86_64-apple-darwin |
| 25 | + os: macos-latest |
| 26 | + - target: aarch64-apple-darwin |
| 27 | + os: macos-latest |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Setup Rust |
| 33 | + uses: dtolnay/rust-toolchain@stable |
| 34 | + with: |
| 35 | + targets: ${{ matrix.target }} |
| 36 | + |
| 37 | + - name: Install cross |
| 38 | + if: matrix.use-cross == true |
| 39 | + uses: taiki-e/install-action@cross |
| 40 | + |
| 41 | + - name: Build |
| 42 | + if: matrix.use-cross != true |
| 43 | + run: cargo build --release --target ${{ matrix.target }} |
| 44 | + |
| 45 | + - name: Build with cross |
| 46 | + if: matrix.use-cross == true |
| 47 | + run: cross build --release --target ${{ matrix.target }} |
| 48 | + |
| 49 | + - name: Prepare asset |
| 50 | + run: | |
| 51 | + mkdir -p dist |
| 52 | + cp target/${{ matrix.target }}/release/dotup dist/dotup-${{ matrix.target }} |
| 53 | +
|
| 54 | + - name: Upload artifact |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: dotup-${{ matrix.target }} |
| 58 | + path: dist/dotup-${{ matrix.target }} |
| 59 | + |
| 60 | + release: |
| 61 | + name: Create Release |
| 62 | + needs: build |
| 63 | + runs-on: ubuntu-latest |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - name: Download all artifacts |
| 68 | + uses: actions/download-artifact@v4 |
| 69 | + with: |
| 70 | + path: artifacts |
| 71 | + merge-multiple: true |
| 72 | + |
| 73 | + - name: Create Release |
| 74 | + uses: softprops/action-gh-release@v2 |
| 75 | + if: startsWith(github.ref, 'refs/tags/') |
| 76 | + with: |
| 77 | + name: Release ${{ github.ref_name }} |
| 78 | + files: artifacts/* |
| 79 | + |
| 80 | + - name: Create Release (Manual) |
| 81 | + uses: softprops/action-gh-release@v2 |
| 82 | + if: "!startsWith(github.ref, 'refs/tags/')" |
| 83 | + with: |
| 84 | + tag_name: latest |
| 85 | + name: Latest Build |
| 86 | + files: artifacts/* |
0 commit comments