|
5 | 5 | branches:
|
6 | 6 | - release
|
7 | 7 |
|
8 |
| -# This is the example from the readme. |
9 |
| -# On each push to the `release` branch it will create or update a GitHub release, build your app, and upload the artifacts to the release. |
10 | 8 | env:
|
11 | 9 | CARGO_TERM_COLOR: always
|
12 |
| - BINARY_PREFIX: ncbi |
13 | 10 |
|
14 | 11 | jobs:
|
15 |
| - build-and-release: |
16 |
| - permissions: |
17 |
| - contents: write |
| 12 | + build-cross: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + env: |
| 15 | + RUST_BACKTRACE: full |
18 | 16 | strategy:
|
19 | 17 | fail-fast: false
|
20 | 18 | matrix:
|
21 |
| - platform: [macos-latest, ubuntu-20.04, windows-latest] |
| 19 | + target: |
| 20 | + - i686-unknown-linux-musl |
| 21 | + - x86_64-pc-windows-gnu |
| 22 | + - x86_64-unknown-linux-gnu |
| 23 | + - x86_64-unknown-linux-musl |
| 24 | + - armv7-unknown-linux-musleabihf |
| 25 | + - armv7-unknown-linux-gnueabihf |
| 26 | + - arm-unknown-linux-gnueabi |
| 27 | + - arm-unknown-linux-gnueabihf |
| 28 | + - arm-unknown-linux-musleabi |
| 29 | + - arm-unknown-linux-musleabihf |
| 30 | + - aarch64-unknown-linux-gnu |
| 31 | + - aarch64-unknown-linux-musl |
| 32 | + - mips-unknown-linux-musl |
| 33 | + - mipsel-unknown-linux-musl |
22 | 34 |
|
23 |
| - runs-on: ${{ matrix.platform }} |
24 | 35 | steps:
|
25 |
| - - uses: actions/checkout@v4 |
26 |
| - - name: Build |
27 |
| - run: cargo build --release |
| 36 | + - uses: actions/checkout@v3 |
28 | 37 |
|
29 |
| - # Set up the GitHub CLI |
30 |
| - - name: Install GitHub CLI |
| 38 | + - name: Install Rust |
31 | 39 | run: |
|
32 |
| - brew install gh |
33 |
| - if: matrix.platform == 'macos-latest' |
| 40 | + rustup set profile minimal |
| 41 | + rustup toolchain install stable |
| 42 | + rustup default stable |
| 43 | + rustup override set stable |
| 44 | + rustup target add --toolchain stable ${{ matrix.target }} |
34 | 45 |
|
35 |
| - - name: Install GitHub CLI |
36 |
| - run: | |
37 |
| - sudo apt install -y gh |
38 |
| - if: matrix.platform == 'ubuntu-20.04' |
| 46 | + - name: Install cross |
| 47 | + run: cargo install cross |
39 | 48 |
|
40 |
| - - name: Install GitHub CLI |
| 49 | + - name: Build ${{ matrix.target }} |
| 50 | + timeout-minutes: 120 |
41 | 51 | run: |
|
42 |
| - choco install gh |
43 |
| - if: matrix.platform == 'windows-latest' |
| 52 | + compile_target=${{ matrix.target }} |
| 53 | +
|
| 54 | + if [[ "$compile_target" == *"-linux-"* || "$compile_target" == *"-apple-"* ]]; then |
| 55 | + compile_features="-f local-redir -f local-tun" |
| 56 | + fi |
| 57 | +
|
| 58 | + if [[ "$compile_target" == "mips-"* || "$compile_target" == "mipsel-"* || "$compile_target" == "mips64-"* || "$compile_target" == "mips64el-"* ]]; then |
| 59 | + sudo apt-get update -y && sudo apt-get install -y upx; |
| 60 | + if [[ "$?" == "0" ]]; then |
| 61 | + compile_compress="-u" |
| 62 | + fi |
| 63 | + fi |
| 64 | +
|
| 65 | + cd build |
| 66 | + ./build-release -t ${{ matrix.target }} $compile_features $compile_compress |
| 67 | +
|
| 68 | + - name: Upload Github Assets |
| 69 | + uses: softprops/action-gh-release@v1 |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + with: |
| 73 | + files: build/release/* |
| 74 | + prerelease: ${{ contains(github.ref_name, '-') }} |
| 75 | + tag_name: ${{ inputs.tag || github.ref_name }} |
| 76 | + |
| 77 | + build-unix: |
| 78 | + runs-on: ${{ matrix.os }} |
| 79 | + env: |
| 80 | + BUILD_EXTRA_FEATURES: "local-redir local-tun" |
| 81 | + RUST_BACKTRACE: full |
| 82 | + strategy: |
| 83 | + fail-fast: false |
| 84 | + matrix: |
| 85 | + # os: [ubuntu-latest, macos-latest] |
| 86 | + os: [macos-latest] |
| 87 | + target: |
| 88 | + - x86_64-apple-darwin |
| 89 | + - aarch64-apple-darwin |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v3 |
44 | 92 |
|
45 |
| - # Log in to the GitHub CLI |
46 |
| - - name: Login to GitHub CLI |
47 |
| - run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token |
| 93 | + - name: Install GNU tar |
| 94 | + if: runner.os == 'macOS' |
| 95 | + run: | |
| 96 | + brew install gnu-tar |
| 97 | + # echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin" |
| 98 | + echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH |
48 | 99 |
|
49 |
| - # Create a release |
50 |
| - - name: Create Release |
51 |
| - id: create_release |
| 100 | + - name: Install Rust |
52 | 101 | run: |
|
53 |
| - gh release create ${{ github.ref_name }} \ |
54 |
| - --title "Release ${{ github.ref_name }}" \ |
55 |
| - --notes "Release notes for ${{ github.ref_name }}" \ |
56 |
| - --draft |
| 102 | + rustup set profile minimal |
| 103 | + rustup toolchain install stable |
| 104 | + rustup default stable |
| 105 | + rustup override set stable |
| 106 | + rustup target add --toolchain stable ${{ matrix.target }} |
| 107 | +
|
| 108 | + - name: Build release |
57 | 109 | shell: bash
|
| 110 | + run: | |
| 111 | + ./build/build-host-release -t ${{ matrix.target }} |
| 112 | +
|
| 113 | + - name: Upload Github Assets |
| 114 | + uses: softprops/action-gh-release@v1 |
| 115 | + env: |
| 116 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + with: |
| 118 | + files: build/release/* |
| 119 | + prerelease: ${{ contains(github.ref_name, '-') }} |
| 120 | + tag_name: ${{ inputs.tag || github.ref_name }} |
58 | 121 |
|
59 |
| - - name: Rename and prepare binaries for upload |
| 122 | + build-windows: |
| 123 | + runs-on: windows-latest |
| 124 | + env: |
| 125 | + RUSTFLAGS: "-C target-feature=+crt-static" |
| 126 | + RUST_BACKTRACE: full |
| 127 | + steps: |
| 128 | + - uses: actions/checkout@v3 |
| 129 | + |
| 130 | + - name: Install Rust |
60 | 131 | run: |
|
61 |
| - EXT="" |
62 |
| - if [ "${{ runner.os }}" = "Windows" ]; then |
63 |
| - EXT=".exe" |
64 |
| - fi |
65 |
| - for file in "${BINARY_PREFIX}"*; do |
66 |
| - mv "$file" "${file}-${RUNNER_OS}-${RUNNER_ARCH}${EXT}" |
67 |
| - done |
68 |
| - echo "Renamed binaries for upload" |
69 |
| - shell: bash |
| 132 | + rustup set profile minimal |
| 133 | + rustup toolchain install stable |
| 134 | + rustup default stable |
| 135 | + rustup override set stable |
| 136 | +
|
| 137 | + - name: Build release |
| 138 | + run: | |
| 139 | + pwsh ./build/build-host-release.ps1 |
70 | 140 |
|
71 |
| - - name: Upload Artifacts |
72 |
| - uses: actions/upload-artifact@v3 |
| 141 | + - name: Upload Github Assets |
| 142 | + uses: softprops/action-gh-release@v1 |
| 143 | + env: |
| 144 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
73 | 145 | with:
|
74 |
| - name: ${{ env.BINARY_PREFIX }}-${{ runner.os }}-${{ runner.arch }} |
75 |
| - path: | |
76 |
| - ${BINARY_PREFIX}*-${RUNNER_OS}-${RUNNER_ARCH}${EXT} |
| 146 | + files: build/release/* |
| 147 | + prerelease: ${{ contains(github.ref_name, '-') }} |
| 148 | + tag_name: ${{ inputs.tag || github.ref_name }} |
0 commit comments