|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - os: macos-14 |
| 19 | + target: aarch64-apple-darwin |
| 20 | + - os: ubuntu-latest |
| 21 | + target: x86_64-unknown-linux-musl |
| 22 | + |
| 23 | + env: |
| 24 | + ASSET_BASENAME: gitee-${{ github.ref_name }}-${{ matrix.target }} |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Check out repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Read Rust version |
| 31 | + id: rust-version |
| 32 | + run: echo "version=$(awk '/^rust / { print $2 }' .tool-versions)" >> "$GITHUB_OUTPUT" |
| 33 | + |
| 34 | + - name: Install Rust toolchain |
| 35 | + run: | |
| 36 | + rustup toolchain install "${{ steps.rust-version.outputs.version }}" --profile minimal |
| 37 | + rustup default "${{ steps.rust-version.outputs.version }}" |
| 38 | + rustup target add "${{ matrix.target }}" |
| 39 | +
|
| 40 | + - name: Install musl tools |
| 41 | + if: matrix.target == 'x86_64-unknown-linux-musl' |
| 42 | + run: | |
| 43 | + sudo apt-get update |
| 44 | + sudo apt-get install -y musl-tools |
| 45 | +
|
| 46 | + - name: Build release binary |
| 47 | + run: cargo build --locked --release --target "${{ matrix.target }}" |
| 48 | + |
| 49 | + - name: Package release archive |
| 50 | + run: | |
| 51 | + mkdir -p "dist/${ASSET_BASENAME}" |
| 52 | + cp "target/${{ matrix.target }}/release/gitee" "dist/${ASSET_BASENAME}/gitee" |
| 53 | + cp LICENSE README.md README_CN.md "dist/${ASSET_BASENAME}/" |
| 54 | + tar -C dist -czf "dist/${ASSET_BASENAME}.tar.gz" "${ASSET_BASENAME}" |
| 55 | +
|
| 56 | + - name: Upload release archive |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: ${{ matrix.target }} |
| 60 | + path: dist/${{ env.ASSET_BASENAME }}.tar.gz |
| 61 | + if-no-files-found: error |
| 62 | + |
| 63 | + publish: |
| 64 | + needs: build |
| 65 | + runs-on: ubuntu-latest |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Download release archives |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + path: release-assets |
| 72 | + merge-multiple: true |
| 73 | + |
| 74 | + - name: Generate checksums |
| 75 | + run: | |
| 76 | + cd release-assets |
| 77 | + shasum -a 256 *.tar.gz > "gitee-${GITHUB_REF_NAME}-checksums.txt" |
| 78 | +
|
| 79 | + - name: Create or update draft GitHub release |
| 80 | + uses: softprops/action-gh-release@v2 |
| 81 | + with: |
| 82 | + draft: true |
| 83 | + generate_release_notes: true |
| 84 | + overwrite_files: true |
| 85 | + fail_on_unmatched_files: true |
| 86 | + working_directory: release-assets |
| 87 | + files: | |
| 88 | + *.tar.gz |
| 89 | + gitee-${{ github.ref_name }}-checksums.txt |
0 commit comments