|
| 1 | +name: GitHub Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - v[0-9]+.[0-9]+.[0-9]+* |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Publish to Github Relases |
| 11 | + outputs: |
| 12 | + rc: ${{ steps.check-tag.outputs.rc }} |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - target: aarch64-unknown-linux-musl |
| 18 | + os: ubuntu-latest |
| 19 | + use-cross: true |
| 20 | + cargo-flags: "" |
| 21 | + - target: aarch64-apple-darwin |
| 22 | + os: macos-latest |
| 23 | + use-cross: true |
| 24 | + cargo-flags: "" |
| 25 | + - target: aarch64-pc-windows-msvc |
| 26 | + os: windows-latest |
| 27 | + use-cross: true |
| 28 | + cargo-flags: "--no-default-features" |
| 29 | + - target: x86_64-apple-darwin |
| 30 | + os: macos-latest |
| 31 | + cargo-flags: "" |
| 32 | + - target: x86_64-pc-windows-msvc |
| 33 | + os: windows-latest |
| 34 | + cargo-flags: "" |
| 35 | + - target: x86_64-unknown-linux-musl |
| 36 | + os: ubuntu-latest |
| 37 | + use-cross: true |
| 38 | + cargo-flags: "" |
| 39 | + - target: i686-unknown-linux-musl |
| 40 | + os: ubuntu-latest |
| 41 | + use-cross: true |
| 42 | + cargo-flags: "" |
| 43 | + - target: i686-pc-windows-msvc |
| 44 | + os: windows-latest |
| 45 | + use-cross: true |
| 46 | + cargo-flags: "" |
| 47 | + - target: armv7-unknown-linux-musleabihf |
| 48 | + os: ubuntu-latest |
| 49 | + use-cross: true |
| 50 | + cargo-flags: "" |
| 51 | + - target: arm-unknown-linux-musleabihf |
| 52 | + os: ubuntu-latest |
| 53 | + use-cross: true |
| 54 | + cargo-flags: "" |
| 55 | + - target: mips-unknown-linux-musl |
| 56 | + os: ubuntu-latest |
| 57 | + use-cross: true |
| 58 | + cargo-flags: "--no-default-features" |
| 59 | + - target: mipsel-unknown-linux-musl |
| 60 | + os: ubuntu-latest |
| 61 | + use-cross: true |
| 62 | + cargo-flags: "--no-default-features" |
| 63 | + - target: mips64-unknown-linux-gnuabi64 |
| 64 | + os: ubuntu-latest |
| 65 | + use-cross: true |
| 66 | + cargo-flags: "--no-default-features" |
| 67 | + - target: mips64el-unknown-linux-gnuabi64 |
| 68 | + os: ubuntu-latest |
| 69 | + use-cross: true |
| 70 | + cargo-flags: "--no-default-features" |
| 71 | + runs-on: ${{matrix.os}} |
| 72 | + |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v2 |
| 75 | + |
| 76 | + - name: Check Tag |
| 77 | + id: check-tag |
| 78 | + shell: bash |
| 79 | + run: | |
| 80 | + tag=${GITHUB_REF##*/} |
| 81 | + echo "::set-output name=version::$tag" |
| 82 | + if [[ "$tag" =~ [0-9]+.[0-9]+.[0-9]+$ ]]; then |
| 83 | + echo "::set-output name=rc::false" |
| 84 | + else |
| 85 | + echo "::set-output name=rc::true" |
| 86 | + fi |
| 87 | + - name: Install Rust Toolchain Components |
| 88 | + uses: actions-rs/toolchain@v1 |
| 89 | + with: |
| 90 | + override: true |
| 91 | + target: ${{ matrix.target }} |
| 92 | + toolchain: stable |
| 93 | + profile: minimal # minimal component installation (ie, no documentation) |
| 94 | + |
| 95 | + - name: Install OpenSSL |
| 96 | + if: runner.os == 'Linux' |
| 97 | + run: sudo apt-get install -y libssl-dev |
| 98 | + |
| 99 | + - name: Show Version Information (Rust, cargo, GCC) |
| 100 | + shell: bash |
| 101 | + run: | |
| 102 | + gcc --version || true |
| 103 | + rustup -V |
| 104 | + rustup toolchain list |
| 105 | + rustup default |
| 106 | + cargo -V |
| 107 | + rustc -V |
| 108 | + |
| 109 | + - name: Build |
| 110 | + uses: actions-rs/cargo@v1 |
| 111 | + with: |
| 112 | + use-cross: ${{ matrix.use-cross }} |
| 113 | + command: build |
| 114 | + args: --locked --release --target=${{ matrix.target }} ${{ matrix.cargo-flags }} |
| 115 | + |
| 116 | + - name: Build Archive |
| 117 | + shell: bash |
| 118 | + id: package |
| 119 | + env: |
| 120 | + target: ${{ matrix.target }} |
| 121 | + version: ${{ steps.check-tag.outputs.version }} |
| 122 | + run: | |
| 123 | + set -euxo pipefail |
| 124 | + bin=${GITHUB_REPOSITORY##*/} |
| 125 | + src=`pwd` |
| 126 | + dist=$src/dist |
| 127 | + name=$bin-$version-$target |
| 128 | + executable=target/$target/release/$bin |
| 129 | + if [[ "$RUNNER_OS" == "Windows" ]]; then |
| 130 | + executable=$executable.exe |
| 131 | + fi |
| 132 | + mkdir $dist |
| 133 | + cp $executable $dist |
| 134 | + cd $dist |
| 135 | + if [[ "$RUNNER_OS" == "Windows" ]]; then |
| 136 | + archive=$dist/$name.zip |
| 137 | + 7z a $archive * |
| 138 | + echo "::set-output name=archive::`pwd -W`/$name.zip" |
| 139 | + else |
| 140 | + archive=$dist/$name.tar.gz |
| 141 | + tar czf $archive * |
| 142 | + echo "::set-output name=archive::$archive" |
| 143 | + fi |
| 144 | + - name: Publish Archive |
| 145 | + |
| 146 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 147 | + with: |
| 148 | + draft: false |
| 149 | + files: ${{ steps.package.outputs.archive }} |
| 150 | + prerelease: ${{ steps.check-tag.outputs.rc == 'true' }} |
| 151 | + env: |
| 152 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments