|
| 1 | +name: Test and build dyn-wall-rs for Linux and Windows |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - "v*" |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ${{ matrix.os }} |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + os: [ubuntu-latest, windows-latest] |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Cache Deps |
| 16 | + |
| 17 | + with: |
| 18 | + path: | |
| 19 | + ~/.cargo/registry |
| 20 | + ~/.cargo/git |
| 21 | + target |
| 22 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 23 | + |
| 24 | + - uses: actions/checkout@v2 |
| 25 | + - name: Run tests |
| 26 | + run: cargo test --verbose |
| 27 | + |
| 28 | + release-linux: |
| 29 | + needs: test |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v2 |
| 33 | + |
| 34 | + - name: Cache Deps |
| 35 | + |
| 36 | + with: |
| 37 | + path: | |
| 38 | + ~/.cargo/registry |
| 39 | + ~/.cargo/git |
| 40 | + target |
| 41 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 42 | + |
| 43 | + - name: Build |
| 44 | + run: cargo build --release |
| 45 | + |
| 46 | + - name: Copy binary over |
| 47 | + run: cp target/release/dyn-wall-rs . |
| 48 | + |
| 49 | + - name: Pack into tarball |
| 50 | + run: tar -czvf dyn-wall-rs-linux.tar.gz dyn-wall-rs |
| 51 | + |
| 52 | + - name: Find sha265sum |
| 53 | + run: sha256sum dyn-wall-rs-linux.tar.gz > dyn-wall-rs-linux.sha256 |
| 54 | + |
| 55 | + - name: Create Release |
| 56 | + id: create_release |
| 57 | + uses: actions/create-release@v1 |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + with: |
| 61 | + tag_name: ${{ github.ref }} |
| 62 | + release_name: ${{ github.ref }} |
| 63 | + draft: false |
| 64 | + prerelease: false |
| 65 | + |
| 66 | + - name: Upload Linux zip |
| 67 | + id: upload-linux-zip |
| 68 | + uses: actions/upload-release-asset@v1 |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + |
| 72 | + with: |
| 73 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 74 | + asset_path: dyn-wall-rs-linux.tar.gz |
| 75 | + asset_name: dyn-wall-rs-linux.tar.gz |
| 76 | + asset_content_type: application/zip |
| 77 | + |
| 78 | + - name: Upload Linux sha256 |
| 79 | + id: upload-linux-sha256 |
| 80 | + uses: actions/upload-release-asset@v1 |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + |
| 84 | + with: |
| 85 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 86 | + asset_path: dyn-wall-rs-linux.sha256 |
| 87 | + asset_name: dyn-wall-rs-linux.sha256 |
| 88 | + asset_content_type: application/zip |
| 89 | + |
| 90 | + release-windows: |
| 91 | + needs: test |
| 92 | + runs-on: windows-latest |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v2 |
| 95 | + |
| 96 | + - name: Cache Deps |
| 97 | + |
| 98 | + with: |
| 99 | + path: | |
| 100 | + ~/.cargo/registry |
| 101 | + ~/.cargo/git |
| 102 | + target |
| 103 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 104 | + - name: Build |
| 105 | + run: cargo build --release |
| 106 | + |
| 107 | + - name: Copy .exe over |
| 108 | + run: Copy-Item -Path target\release\dyn-wall-rs.exe |
| 109 | + |
| 110 | + - name: zip .exe |
| 111 | + run: tar.exe -a -cf dyn-wall-rs-windows.zip dyn-wall-rs.exe |
| 112 | + |
| 113 | + - name: Find sha265sum |
| 114 | + run: Get-FileHash dyn-wall-rs-windows.zip -Algorithm SHA256 | Format-List > dyn-wall-rs-windows.sha256 |
| 115 | + |
| 116 | + - name: Get the version |
| 117 | + id: get_version |
| 118 | + shell: bash |
| 119 | + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} |
| 120 | + |
| 121 | + |
| 122 | + with: |
| 123 | + files: 'dyn-wall-rs-windows.zip;dyn-wall-rs-windows.sha256' |
| 124 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 125 | + release-tag: ${{ steps.get_version.outputs.VERSION }} |
0 commit comments