|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + timeout-minutes: 2 |
| 10 | + |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + include: |
| 14 | + # wasm stable |
| 15 | + - name: 'stable wasm' |
| 16 | + os: 'ubuntu-latest' |
| 17 | + target: 'wasm32-unknown-unknown' |
| 18 | + rust_version: 'stable' |
| 19 | + |
| 20 | + # native stable |
| 21 | + - name: 'stable linux' |
| 22 | + os: 'ubuntu-latest' |
| 23 | + target: 'x86_64-unknown-linux-gnu' |
| 24 | + rust_version: 'stable' |
| 25 | + - name: 'stable mac' |
| 26 | + os: 'macos-latest' |
| 27 | + target: 'x86_64-apple-darwin' |
| 28 | + rust_version: 'stable' |
| 29 | + - name: 'stable windows' |
| 30 | + os: 'windows-latest' |
| 31 | + target: 'x86_64-pc-windows-msvc' |
| 32 | + rust_version: 'stable' |
| 33 | + |
| 34 | + fail-fast: false |
| 35 | + |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + name: ${{ matrix.name }} |
| 38 | + |
| 39 | + steps: |
| 40 | + - name: checkout repo |
| 41 | + uses: actions/checkout@v2 |
| 42 | + |
| 43 | + - name: install rust |
| 44 | + uses: actions-rs/toolchain@v1 |
| 45 | + with: |
| 46 | + toolchain: ${{ matrix.rust_version }} |
| 47 | + target: ${{ matrix.target }} |
| 48 | + profile: minimal |
| 49 | + components: clippy |
| 50 | + default: true |
| 51 | + |
| 52 | + - name: caching |
| 53 | + uses: Swatinem/rust-cache@v1 |
| 54 | + with: |
| 55 | + key: ${{ matrix.target }}-a # suffix for cache busting |
| 56 | + |
| 57 | + - name: check |
| 58 | + uses: actions-rs/cargo@v1 |
| 59 | + with: |
| 60 | + command: clippy |
| 61 | + args: --target ${{ matrix.target }} -- -D warnings |
| 62 | + |
| 63 | + - name: build |
| 64 | + uses: actions-rs/cargo@v1 |
| 65 | + with: |
| 66 | + command: build |
| 67 | + args: --target ${{ matrix.target }} |
| 68 | + |
| 69 | + - name: test |
| 70 | + uses: actions-rs/cargo@v1 |
| 71 | + with: |
| 72 | + command: test |
| 73 | + if: ${{ matrix.name != 'wasm' }} |
| 74 | + |
| 75 | + - name: doc |
| 76 | + uses: actions-rs/cargo@v1 |
| 77 | + env: |
| 78 | + RUSTDOCFLAGS: -D warnings |
| 79 | + with: |
| 80 | + command: doc |
| 81 | + args: --no-deps --target ${{ matrix.target }} |
| 82 | + |
| 83 | + cargo-fmt: |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - name: checkout repo |
| 87 | + uses: actions/checkout@v2 |
| 88 | + |
| 89 | + - name: install rust |
| 90 | + uses: actions-rs/toolchain@v1 |
| 91 | + with: |
| 92 | + toolchain: nightly |
| 93 | + profile: minimal |
| 94 | + components: rustfmt |
| 95 | + default: true |
| 96 | + |
| 97 | + - name: check format |
| 98 | + uses: actions-rs/cargo@v1 |
| 99 | + with: |
| 100 | + command: fmt |
| 101 | + args: -- --check |
| 102 | + |
| 103 | + cargo-deny: |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + - name: checkout repo |
| 107 | + uses: actions/checkout@v2 |
| 108 | + |
| 109 | + - name: check denies |
| 110 | + uses: EmbarkStudios/cargo-deny-action@v1 |
| 111 | + with: |
| 112 | + log-level: warn |
| 113 | + command: check |
| 114 | + arguments: --all-features |
| 115 | + |
| 116 | + publish: |
| 117 | + runs-on: ubuntu-latest |
| 118 | + |
| 119 | + needs: ['build', 'cargo-fmt', 'cargo-deny'] |
| 120 | + if: ${{ startsWith(github.ref, 'refs/tags/v') }} |
| 121 | + |
| 122 | + steps: |
| 123 | + - name: checkout repo |
| 124 | + uses: actions/checkout@v2 |
| 125 | + with: |
| 126 | + fetch-depth: 0 |
| 127 | + |
| 128 | + - name: install rust |
| 129 | + uses: actions-rs/toolchain@v1 |
| 130 | + with: |
| 131 | + toolchain: stable |
| 132 | + profile: minimal |
| 133 | + default: true |
| 134 | + |
| 135 | + - name: install cargo-readme |
| 136 | + run: | |
| 137 | + cargo install cargo-readme |
| 138 | + |
| 139 | + - name: install cargo-release |
| 140 | + run: | |
| 141 | + cargo install cargo-release |
| 142 | +
|
| 143 | + - name: release to crates.io |
| 144 | + run: | |
| 145 | + git config user.name "releasebot" |
| 146 | + git config user.email "[email protected]" |
| 147 | + git checkout trunk |
| 148 | +
|
| 149 | + cargo login ${{ secrets.CRATES_TOKEN }} |
| 150 | + cargo release --skip-publish --no-confirm $( echo '${{ github.ref }}' | sed 's?refs/tags/v??' ) |
| 151 | + |
| 152 | + - name: generate release notes |
| 153 | + id: notes |
| 154 | + run: | |
| 155 | + NOTES=$(python -c 'import re; print(re.search("## v\\d+.\\d+.\\d+\n\nReleased \\d+-\\d+-\\d+\n\n((?:[\n]|.)*?)(?=## [vD])", open("CHANGELOG.md", "r").read()).group(1).strip().replace("%", "%25").replace("\n", "%0A"))') |
| 156 | + echo "::set-output name=notes::$NOTES" |
| 157 | +
|
| 158 | + - name: release to github |
| 159 | + uses: actions/create-release@v1 |
| 160 | + env: |
| 161 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 162 | + with: |
| 163 | + tag_name: ${{ github.ref }} |
| 164 | + release_name: ${{ github.ref }} |
| 165 | + body: ${{ steps.notes.outputs.notes }} |
| 166 | + draft: false |
| 167 | + prerelease: false |
| 168 | + |
| 169 | + |
0 commit comments