|
| 1 | +name: Continuous Deployment |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '[0-9]+.[0-9]+.[0-9]+' |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish: |
| 10 | + name: Publishing for ${{ matrix.os }} |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 15 | + rust: [stable] |
| 16 | + include: |
| 17 | + - os: macos-latest |
| 18 | + artifact_prefix: macos |
| 19 | + target: x86_64-apple-darwin |
| 20 | + binary_postfix: "" |
| 21 | + - os: ubuntu-latest |
| 22 | + artifact_prefix: linux |
| 23 | + target: x86_64-unknown-linux-gnu |
| 24 | + binary_postfix: "" |
| 25 | + - os: windows-latest |
| 26 | + artifact_prefix: windows |
| 27 | + target: x86_64-pc-windows-msvc |
| 28 | + binary_postfix: ".exe" |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Installing Rust toolchain |
| 32 | + uses: actions-rs/toolchain@v1 |
| 33 | + with: |
| 34 | + toolchain: ${{ matrix.rust }} |
| 35 | + override: true |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v2 |
| 38 | + - name: Cargo build |
| 39 | + uses: actions-rs/cargo@v1 |
| 40 | + with: |
| 41 | + command: build |
| 42 | + toolchain: ${{ matrix.rust }} |
| 43 | + args: --release --target ${{ matrix.target }} |
| 44 | + |
| 45 | + - name: Packaging final binary |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + cd target/${{ matrix.target }}/release |
| 49 | + strip spt${{ matrix.binary_postfix }} |
| 50 | + tar czvf rust-gh-example-${{ matrix.artifact_prefix }}.tar.gz spt${{ matrix.binary_postfix }} |
| 51 | +
|
| 52 | + if [[ ${{ runner.os }} == 'Windows' ]]; then |
| 53 | + certutil -hashfile rust-gh-example-${{ matrix.artifact_prefix }}.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > rust-gh-example-${{ matrix.artifact_prefix }}.sha256 |
| 54 | + else |
| 55 | + shasum -a 256 rust-gh-example-${{ matrix.artifact_prefix }}.tar.gz > rust-gh-example-${{ matrix.artifact_prefix }}.sha256 |
| 56 | + fi |
| 57 | + - name: Releasing assets |
| 58 | + uses: softprops/action-gh-release@v1 |
| 59 | + with: |
| 60 | + files: | |
| 61 | + target/${{ matrix.target }}/release/rust-gh-example-${{ matrix.artifact_prefix }}.tar.gz |
| 62 | + target/${{ matrix.target }}/release/rust-gh-example-${{ matrix.artifact_prefix }}.sha256 |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + |
| 66 | + publish-cargo: |
| 67 | + name: Publishing to Cargo |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@master |
| 71 | + - uses: actions-rs/toolchain@v1 |
| 72 | + with: |
| 73 | + toolchain: stable |
| 74 | + override: true |
| 75 | + - uses: actions-rs/cargo@v1 |
| 76 | + with: |
| 77 | + command: publish |
| 78 | + args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty |
0 commit comments