|
1 | 1 | name: Continuous integration
|
2 | 2 | on: [push, pull_request]
|
| 3 | +defaults: |
| 4 | + run: |
| 5 | + shell: bash |
3 | 6 | jobs:
|
4 |
| - ci: |
| 7 | + ci-linux: |
5 | 8 | name: Build and test on Linux
|
6 | 9 | runs-on: ubuntu-latest
|
7 | 10 | steps:
|
8 | 11 | - uses: actions/checkout@v2
|
9 |
| - - uses: azure/docker-login@v1 |
| 12 | + - if: ${{ github.event_name == 'push' }} |
| 13 | + uses: azure/docker-login@v1 |
10 | 14 | with:
|
11 | 15 | username: stephanmisc
|
12 | 16 | password: ${{ secrets.DOCKER_PASSWORD }}
|
13 |
| - if: github.event_name == 'push' |
14 | 17 | - uses: stepchowfun/toast/.github/actions/toast@main
|
15 | 18 | with:
|
16 |
| - tasks: build check test lint run |
| 19 | + tasks: build test lint release run |
17 | 20 | repo: stephanmisc/toast
|
18 | 21 | write_remote_cache: ${{ github.event_name == 'push' }}
|
| 22 | + - run: | |
| 23 | + # Make Bash not silently ignore errors. |
| 24 | + set -euo pipefail |
| 25 | +
|
| 26 | + # The artifact name will contain the target triple, so the file name doesn't need to. |
| 27 | + mv artifacts/paxos-x86_64-unknown-linux-gnu artifacts/paxos |
| 28 | + - uses: actions/upload-artifact@v2 |
| 29 | + with: |
| 30 | + name: x86_64-unknown-linux-gnu |
| 31 | + path: artifacts/paxos |
| 32 | + if-no-files-found: error |
| 33 | + - run: | |
| 34 | + # Make Bash not silently ignore errors. |
| 35 | + set -euo pipefail |
| 36 | +
|
| 37 | + # The artifact name will contain the target triple, so the file name doesn't need to. |
| 38 | + mv artifacts/paxos-x86_64-unknown-linux-musl artifacts/paxos |
| 39 | + - uses: actions/upload-artifact@v2 |
| 40 | + with: |
| 41 | + name: x86_64-unknown-linux-musl |
| 42 | + path: artifacts/paxos |
| 43 | + if-no-files-found: error |
| 44 | + ci-macos: |
| 45 | + name: Build and test on macOS |
| 46 | + runs-on: macos-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v2 |
| 49 | + - run: | |
| 50 | + # Make Bash not silently ignore errors. |
| 51 | + set -euo pipefail |
| 52 | +
|
| 53 | + rustup toolchain install 1.53.0 # [ref:rust_1_53_0] |
| 54 | + rustup default 1.53.0 # [ref:rust_1_53_0] |
| 55 | + - run: | |
| 56 | + # Make Bash not silently ignore errors. |
| 57 | + set -euo pipefail |
| 58 | +
|
| 59 | + # Build and test. |
| 60 | + cargo build --locked --release --target x86_64-apple-darwin |
| 61 | + NO_COLOR=true cargo test --locked # [ref:colorless_tests] |
| 62 | + - uses: actions/upload-artifact@v2 |
| 63 | + with: |
| 64 | + name: x86_64-apple-darwin |
| 65 | + path: target/x86_64-apple-darwin/release/paxos |
| 66 | + if-no-files-found: error |
| 67 | + ci-windows: |
| 68 | + name: Build and test on Windows |
| 69 | + runs-on: windows-latest |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v2 |
| 72 | + - run: | |
| 73 | + # Make Bash not silently ignore errors. |
| 74 | + set -euo pipefail |
| 75 | +
|
| 76 | + rustup toolchain install 1.53.0 # [ref:rust_1_53_0] |
| 77 | + rustup default 1.53.0 # [ref:rust_1_53_0] |
| 78 | + - run: | |
| 79 | + # Make Bash not silently ignore errors. |
| 80 | + set -euo pipefail |
| 81 | +
|
| 82 | + # Build and test. |
| 83 | + cargo build --locked --release --target x86_64-pc-windows-msvc |
| 84 | + NO_COLOR=true cargo test --locked # [ref:colorless_tests] |
| 85 | + - uses: actions/upload-artifact@v2 |
| 86 | + with: |
| 87 | + name: x86_64-pc-windows-msvc |
| 88 | + path: target/x86_64-pc-windows-msvc/release/paxos.exe |
| 89 | + if-no-files-found: error |
| 90 | + install-macos: |
| 91 | + name: Run the installer script on macOS to validate it |
| 92 | + runs-on: macos-latest |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v2 |
| 95 | + - run: | |
| 96 | + # Make Bash not silently ignore errors. |
| 97 | + set -euo pipefail |
| 98 | +
|
| 99 | + # Run the installer script. |
| 100 | + # PREFIX=/tmp ./install.sh |
| 101 | +
|
| 102 | + # Run the installed binary. |
| 103 | + # /tmp/paxos |
| 104 | + install-ubuntu: |
| 105 | + name: Run the installer script on Ubuntu to validate it |
| 106 | + runs-on: ubuntu-latest |
| 107 | + steps: |
| 108 | + - uses: actions/checkout@v2 |
| 109 | + - run: | |
| 110 | + # Make Bash not silently ignore errors. |
| 111 | + set -euo pipefail |
| 112 | +
|
| 113 | + # Run the installer script. |
| 114 | + # PREFIX=/tmp ./install.sh |
| 115 | +
|
| 116 | + # Run the installed binary. |
| 117 | + # /tmp/paxos |
| 118 | + create-release: |
| 119 | + name: Create a release on GitHub if applicable |
| 120 | + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/windows' }} |
| 121 | + runs-on: ubuntu-latest |
| 122 | + needs: [ci-linux, ci-macos, ci-windows, install-macos, install-ubuntu] |
| 123 | + steps: |
| 124 | + - uses: actions/checkout@v2 |
| 125 | + - uses: actions/download-artifact@v2 |
| 126 | + with: |
| 127 | + path: artifacts/ |
| 128 | + - env: |
| 129 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 130 | + run: | |
| 131 | + # Make Bash not silently ignore errors. |
| 132 | + set -euo pipefail |
| 133 | +
|
| 134 | + # Fetch the program version. |
| 135 | + VERSION="$(cargo pkgid | cut -d# -f2 | cut -d: -f2)" |
| 136 | +
|
| 137 | + # If the release already exists, exit early. |
| 138 | + if hub release show "v$VERSION" &> /dev/null; then |
| 139 | + echo "Release v$VERSION already exists." |
| 140 | + exit |
| 141 | + fi |
| 142 | +
|
| 143 | + # Give the artifacts unique names. |
| 144 | + mv \ |
| 145 | + artifacts/x86_64-unknown-linux-gnu/paxos \ |
| 146 | + artifacts/paxos-x86_64-unknown-linux-gnu |
| 147 | + mv \ |
| 148 | + artifacts/x86_64-unknown-linux-musl/paxos \ |
| 149 | + artifacts/paxos-x86_64-unknown-linux-musl |
| 150 | + mv \ |
| 151 | + artifacts/x86_64-apple-darwin/paxos \ |
| 152 | + artifacts/paxos-x86_64-apple-darwin |
| 153 | + mv \ |
| 154 | + artifacts/x86_64-pc-windows-msvc/paxos.exe \ |
| 155 | + artifacts/paxos-x86_64-pc-windows-msvc.exe |
| 156 | +
|
| 157 | + # Create the release. |
| 158 | + hub release create \ |
| 159 | + --commitish '${{ github.sha }}' \ |
| 160 | + --message "v$VERSION" \ |
| 161 | + --attach 'artifacts/paxos-x86_64-unknown-linux-gnu' \ |
| 162 | + --attach 'artifacts/paxos-x86_64-unknown-linux-musl' \ |
| 163 | + --attach 'artifacts/paxos-x86_64-apple-darwin' \ |
| 164 | + --attach 'artifacts/paxos-x86_64-pc-windows-msvc.exe' \ |
| 165 | + "v$VERSION" |
| 166 | + echo "Created release v$VERSION." |
0 commit comments