|
| 1 | +name: release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - '*' |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-release: |
| 9 | + name: Build on 3 platforms |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + os: [ ubuntu-18.04, windows-2019, macos-10.15 ] |
| 13 | + include: |
| 14 | + - os: ubuntu-18.04 |
| 15 | + os-name: linux |
| 16 | + executable-name: feather-server |
| 17 | + - os: windows-2019 |
| 18 | + os-name: windows |
| 19 | + executable-name: feather-server.exe |
| 20 | + - os: macos-10.15 |
| 21 | + os-name: macOS |
| 22 | + executable-name: feather-server |
| 23 | + |
| 24 | + runs-on: ${{ matrix.os }} |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v2 |
| 28 | + |
| 29 | + # Caching |
| 30 | + - name: Cache cargo registry |
| 31 | + uses: actions/cache@v1 |
| 32 | + with: |
| 33 | + path: ~/.cargo/registry |
| 34 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 35 | + - name: Cache cargo index |
| 36 | + uses: actions/cache@v1 |
| 37 | + with: |
| 38 | + path: ~/.cargo/git |
| 39 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 40 | + - name: Cache cargo build |
| 41 | + uses: actions/cache@v1 |
| 42 | + with: |
| 43 | + path: target |
| 44 | + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} |
| 45 | + |
| 46 | + - name: Build (release mode) |
| 47 | + run: cargo build --release |
| 48 | + |
| 49 | + - name: Get tag name |
| 50 | + uses: olegtarasov/get-tag@v2 |
| 51 | + id: tagName |
| 52 | + |
| 53 | + - name: Compress executable |
| 54 | + uses: papeloto/action-zip@v1 |
| 55 | + with: |
| 56 | + files: target/release/${{ matrix.executable-name }} |
| 57 | + dest: target/release/feather-${{ steps.tagName.outputs.tag }}-${{ matrix.os-name }}.zip |
| 58 | + |
| 59 | + - name: Upload release artifact |
| 60 | + uses: actions/upload-artifact@v2-preview |
| 61 | + with: |
| 62 | + name: ${{ matrix.os-name }} |
| 63 | + path: target/release/feather-${{ steps.tagName.outputs.tag }}-${{ matrix.os-name }}.zip |
| 64 | + |
| 65 | + |
| 66 | + publish: |
| 67 | + name: Publish artifacts to GitHub Releases |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: [build-release] |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Get tag name |
| 73 | + uses: olegtarasov/get-tag@v2 |
| 74 | + id: tagName |
| 75 | + |
| 76 | + - name: Create release |
| 77 | + uses: actions/create-release@v1 |
| 78 | + id: create_release |
| 79 | + env: |
| 80 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + with: |
| 82 | + tag_name: ${{ steps.tagName.outputs.tag }} |
| 83 | + release_name: Release ${{ steps.tagName.outputs.tag }} |
| 84 | + draft: true |
| 85 | + |
| 86 | + - name: Download Linux build |
| 87 | + uses: actions/download-artifact@v1 |
| 88 | + with: |
| 89 | + name: linux |
| 90 | + |
| 91 | + - name: Download Windows build |
| 92 | + uses: actions/download-artifact@v1 |
| 93 | + with: |
| 94 | + name: windows |
| 95 | + |
| 96 | + - name: Download macOS build |
| 97 | + uses: actions/download-artifact@v1 |
| 98 | + with: |
| 99 | + name: macOS |
| 100 | + |
| 101 | + - name: Upload Linux package |
| 102 | + uses: actions/upload-release-asset@v1 |
| 103 | + env: |
| 104 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + with: |
| 106 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 107 | + asset_path: linux/feather-${{ steps.tagName.outputs.tag }}-linux.zip |
| 108 | + asset_name: feather-${{ steps.tagName.outputs.tag }}-linux.zip |
| 109 | + asset_content_type: application/zip |
| 110 | + |
| 111 | + - name: Upload Windows package |
| 112 | + uses: actions/upload-release-asset@v1 |
| 113 | + env: |
| 114 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + with: |
| 116 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 117 | + asset_path: windows/feather-${{ steps.tagName.outputs.tag }}-windows.zip |
| 118 | + asset_name: feather-${{ steps.tagName.outputs.tag }}-windows.zip |
| 119 | + asset_content_type: application/zip |
| 120 | + |
| 121 | + - name: Upload macOS package |
| 122 | + uses: actions/upload-release-asset@v1 |
| 123 | + env: |
| 124 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 125 | + with: |
| 126 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 127 | + asset_path: macOS/feather-${{ steps.tagName.outputs.tag }}-macOS.zip |
| 128 | + asset_name: feather-${{ steps.tagName.outputs.tag }}-macOS.zip |
| 129 | + asset_content_type: application/zip |