|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + release: |
| 5 | + types: [prereleased] |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - master |
| 10 | + - dev* |
| 11 | + - feat* |
| 12 | + - fix* |
| 13 | + - chore* |
| 14 | + - test* |
| 15 | + paths: |
| 16 | + - "**/*.rs" |
| 17 | + - "**/Cargo.toml" |
| 18 | + - "release/" |
| 19 | + - "Cargo.lock" |
| 20 | + - ".github/workflows/release.yml" |
| 21 | + pull_request: |
| 22 | + types: [ opened, synchronize, reopened, ready_for_review ] |
| 23 | + paths: |
| 24 | + - "**/*.rs" |
| 25 | + - "**/Cargo.toml" |
| 26 | + - "release/" |
| 27 | + - "Cargo.lock" |
| 28 | + - ".github/workflows/release.yml" |
| 29 | + |
| 30 | +jobs: |
| 31 | + release: |
| 32 | + strategy: |
| 33 | + fail-fast: false |
| 34 | + matrix: |
| 35 | + include: |
| 36 | + - arch-name: x86_64-unknown-linux-gnu |
| 37 | + os: ubuntu-latest |
| 38 | + target: x86_64-unknown-linux-gnu |
| 39 | + cross: true |
| 40 | + file-ext: |
| 41 | + platform: linux |
| 42 | + |
| 43 | + - arch-name: x86_64-unknown-linux-musl |
| 44 | + os: ubuntu-latest |
| 45 | + target: x86_64-unknown-linux-musl |
| 46 | + cross: true |
| 47 | + file-ext: |
| 48 | + platform: linux |
| 49 | + |
| 50 | + - arch-name: x86_64-unknown-freebsd |
| 51 | + os: ubuntu-latest |
| 52 | + target: x86_64-unknown-freebsd |
| 53 | + cross: true |
| 54 | + file-ext: |
| 55 | + platform: freebsd |
| 56 | + |
| 57 | + - arch-name: x86_64-pc-windows-msvc |
| 58 | + os: windows-latest |
| 59 | + target: x86_64-pc-windows-msvc |
| 60 | + cross: false |
| 61 | + file-ext: .exe |
| 62 | + platform: windows |
| 63 | + |
| 64 | + - arch-name: x86_64-pc-windows-gnu |
| 65 | + os: ubuntu-latest |
| 66 | + target: x86_64-pc-windows-gnu |
| 67 | + cross: true |
| 68 | + file-ext: .exe |
| 69 | + platform: windows |
| 70 | + |
| 71 | + - arch-name: x86_64-apple-darwin |
| 72 | + os: macos-latest |
| 73 | + target: x86_64-apple-darwin |
| 74 | + cross: false |
| 75 | + file-ext: |
| 76 | + platform: darwin |
| 77 | + |
| 78 | + - arch-name: i686-unknown-linux-gnu |
| 79 | + os: ubuntu-latest |
| 80 | + target: i686-unknown-linux-gnu |
| 81 | + cross: true |
| 82 | + file-ext: |
| 83 | + platform: linux |
| 84 | + |
| 85 | + - arch-name: i686-unknown-linux-musl |
| 86 | + os: ubuntu-latest |
| 87 | + target: i686-unknown-linux-musl |
| 88 | + cross: true |
| 89 | + file-ext: |
| 90 | + platform: linux |
| 91 | + |
| 92 | + - arch-name: i686-pc-windows-msvc |
| 93 | + os: windows-latest |
| 94 | + target: i686-pc-windows-msvc |
| 95 | + cross: true |
| 96 | + file-ext: .exe |
| 97 | + platform: windows |
| 98 | + |
| 99 | + - arch-name: aarch64-unknown-linux-gnu |
| 100 | + os: ubuntu-latest |
| 101 | + target: aarch64-unknown-linux-gnu |
| 102 | + cross: true |
| 103 | + file-ext: |
| 104 | + platform: linux |
| 105 | + |
| 106 | + - arch-name: aarch64-unknown-linux-musl |
| 107 | + os: ubuntu-latest |
| 108 | + target: aarch64-unknown-linux-musl |
| 109 | + cross: true |
| 110 | + file-ext: |
| 111 | + platform: linux |
| 112 | + |
| 113 | + - arch-name: aarch64-pc-windows-msvc |
| 114 | + os: windows-latest |
| 115 | + target: aarch64-pc-windows-msvc |
| 116 | + cross: true |
| 117 | + file-ext: .exe |
| 118 | + platform: windows |
| 119 | + |
| 120 | + - arch-name: aarch64-apple-darwin |
| 121 | + os: macos-latest |
| 122 | + target: aarch64-apple-darwin |
| 123 | + cross: true |
| 124 | + file-ext: |
| 125 | + platform: darwin |
| 126 | + |
| 127 | + - arch-name: armv7-unknown-linux-gnueabi |
| 128 | + os: ubuntu-latest |
| 129 | + target: armv7-unknown-linux-gnueabi |
| 130 | + cross: true |
| 131 | + file-ext: |
| 132 | + platform: linux |
| 133 | + |
| 134 | + - arch-name: armv7-unknown-linux-gnueabihf |
| 135 | + os: ubuntu-latest |
| 136 | + target: armv7-unknown-linux-gnueabihf |
| 137 | + cross: true |
| 138 | + file-ext: |
| 139 | + platform: linux |
| 140 | + |
| 141 | + - arch-name: armv7-unknown-linux-musleabi |
| 142 | + os: ubuntu-latest |
| 143 | + target: armv7-unknown-linux-musleabi |
| 144 | + cross: true |
| 145 | + file-ext: |
| 146 | + platform: linux |
| 147 | + |
| 148 | + - arch-name: armv7-unknown-linux-musleabihf |
| 149 | + os: ubuntu-latest |
| 150 | + target: armv7-unknown-linux-musleabihf |
| 151 | + cross: true |
| 152 | + file-ext: |
| 153 | + platform: linux |
| 154 | + |
| 155 | + - arch-name: riscv64gc-unknown-linux-gnu |
| 156 | + os: ubuntu-latest |
| 157 | + target: riscv64gc-unknown-linux-gnu |
| 158 | + cross: true |
| 159 | + file-ext: |
| 160 | + platform: linux |
| 161 | + |
| 162 | + |
| 163 | + runs-on: ${{ matrix.os }} |
| 164 | + |
| 165 | + steps: |
| 166 | + - name: Checkout repository |
| 167 | + uses: actions/checkout@v3 |
| 168 | + with: |
| 169 | + fetch-depth: 0 |
| 170 | + |
| 171 | + - name: Install toolchain |
| 172 | + uses: actions-rs/toolchain@v1 |
| 173 | + with: |
| 174 | + toolchain: stable |
| 175 | + target: ${{ matrix.target }} |
| 176 | + override: true |
| 177 | + |
| 178 | + - name: Build |
| 179 | + uses: actions-rs/cargo@v1 |
| 180 | + with: |
| 181 | + use-cross: ${{ matrix.cross }} |
| 182 | + command: build |
| 183 | + args: --release --target ${{ matrix.target }} |
| 184 | + |
| 185 | + - name: Move binaries |
| 186 | + run: | |
| 187 | + mkdir artifacts/ |
| 188 | + mv target/${{ matrix.target }}/release/asport-client${{ matrix.file-ext }} artifacts/ |
| 189 | + mv target/${{ matrix.target }}/release/asport-server${{ matrix.file-ext }} artifacts/ |
| 190 | +
|
| 191 | + - name: Prepare package |
| 192 | + run: cp *.example.toml artifacts/ |
| 193 | + |
| 194 | + - name: Add systemd service for Linux |
| 195 | + if: matrix.platform == 'linux' |
| 196 | + run: cp -r release/systemd artifacts/ |
| 197 | + |
| 198 | + - name: Archive artifacts |
| 199 | + id: archive |
| 200 | + shell: bash |
| 201 | + run: | |
| 202 | + pushd artifacts |
| 203 | + if ${{ matrix.platform == 'windows' }}; then |
| 204 | + 7z a ../asport-${{ matrix.arch-name }}.zip . |
| 205 | + FILE=asport-${{ matrix.arch-name }}.zip |
| 206 | + else |
| 207 | + tar -cJf ../asport-${{ matrix.arch-name }}.tar.xz . |
| 208 | + FILE=asport-${{ matrix.arch-name }}.tar.xz |
| 209 | + fi |
| 210 | + popd |
| 211 | + |
| 212 | + echo "FILE=$FILE" >> $GITHUB_OUTPUT |
| 213 | +
|
| 214 | + - name: Calculate digest |
| 215 | + shell: bash |
| 216 | + run: | |
| 217 | + DGST=${{ steps.archive.outputs.FILE }}.dgst |
| 218 | + openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 219 | + openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 220 | + openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 221 | + openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 222 | +
|
| 223 | + - name: Upload artifacts |
| 224 | + uses: actions/upload-artifact@v4 |
| 225 | + with: |
| 226 | + name: asport-${{ matrix.arch-name }} |
| 227 | + path: asport-${{ matrix.arch-name }}.* |
| 228 | + |
| 229 | + - name: Upload to GitHub release |
| 230 | + if: github.event_name == 'release' |
| 231 | + uses: softprops/action-gh-release@v1 |
| 232 | + with: |
| 233 | + files: | |
| 234 | + asport-${{ matrix.arch-name }}.* |
| 235 | + file_glob: true |
0 commit comments