|
1 |
| -name: ANTLR4 testsuite |
| 1 | +name: CI |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
|
8 | 8 |
|
9 | 9 | workflow_dispatch:
|
10 | 10 |
|
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + RUST_VERSION: nightly-2021-04-23 |
| 14 | + |
11 | 15 | jobs:
|
12 |
| - build: |
| 16 | + tests-antlr: |
| 17 | + name: ANTLR4 testsuite |
13 | 18 | runs-on: ubuntu-latest
|
14 |
| - |
15 | 19 | steps:
|
16 | 20 | - uses: actions/checkout@v2
|
17 | 21 | with:
|
18 | 22 | repository: rrevenantt/antlr4
|
19 | 23 | ref: rust-target
|
20 | 24 | submodules: true
|
21 |
| - - run: git fetch origin $GITHUB_REF |
| 25 | + - run: | |
| 26 | + git fetch origin $GITHUB_REF |
| 27 | + git checkout FETCH_HEAD |
22 | 28 | working-directory: runtime/Rust
|
23 | 29 | - name: Set up JDK 1.8
|
24 | 30 | uses: actions/setup-java@v1
|
25 | 31 | with:
|
26 | 32 | java-version: 1.8
|
27 | 33 | - name: Install Rust
|
28 |
| - uses: actions-rs/toolchain@v1.0.6 |
| 34 | + uses: actions-rs/toolchain@v1 |
29 | 35 | with:
|
30 |
| - toolchain: nightly-2020-12-23 |
| 36 | + toolchain: ${{ env.RUST_VERSION }} |
31 | 37 | default: true
|
32 | 38 | - name: Cache local Maven repository
|
33 | 39 | uses: actions/cache@v2
|
|
51 | 57 | name: antlr-tool
|
52 | 58 | path: tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar
|
53 | 59 |
|
54 |
| - |
| 60 | + tests-rust: |
| 61 | + name: cargo test |
| 62 | + runs-on: ubuntu-latest |
| 63 | + outputs: |
| 64 | + new_version: ${{ steps.check_ver.outputs.new_version }} |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v2 |
| 67 | + - name: Install Rust |
| 68 | + uses: actions-rs/toolchain@v1 |
| 69 | + with: |
| 70 | + toolchain: ${{ env.RUST_VERSION }} |
| 71 | + default: true |
| 72 | + components: rustfmt |
| 73 | + - name: Build |
| 74 | + run: cargo build --verbose |
| 75 | + - name: Run tests |
| 76 | + run: cargo test --verbose |
| 77 | + - name: Formatting |
| 78 | + run: cargo fmt -- --check |
| 79 | + - uses: actions/checkout@v2 |
| 80 | + if: ${{ github.event_name == 'push' }} |
| 81 | + with: |
| 82 | + ref: ${{ github.event.before }} |
| 83 | + path: base_branch |
| 84 | + - name: check version bump |
| 85 | + if: ${{ github.event_name == 'push' }} |
| 86 | + id: check_ver |
| 87 | + run: | |
| 88 | + NEW_VER = $(cat Cargo.toml | sed -nE "s/^version.*\"([0-9a-z.\-]+)\".*$/\1/p") |
| 89 | + BASE_VER = $(cat base_branch/Cargo.toml | sed -nE "s/^version.*\"([0-9a-z.\-]+)\".*$/\1/p") |
| 90 | + if [[ "$s1" != "$s2" ]] then |
| 91 | + echo "::set-output name=new_version::$NEW_VER" |
| 92 | + fi |
| 93 | +
|
| 94 | + publish: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + if: | |
| 97 | + success() && github.event_name == 'push' |
| 98 | + && needs.tests-rust.outputs.new_version != null |
| 99 | + && needs.tests-rust.outputs.new_version != '' |
| 100 | + needs: [tests-rust,tests-antlr] |
| 101 | + env: |
| 102 | + RELEASE_NAME: ${{ format('antlr4-4.8-2-Rust{0}',needs.tests-rust.outputs.new_version) }} |
| 103 | + PRERELEASE: ${{ contains(needs.tests-rust.outputs.new_version, '-') }} |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v2 |
| 106 | + - name: Install Rust |
| 107 | + uses: actions-rs/toolchain@v1 |
| 108 | + with: |
| 109 | + toolchain: ${{ env.RUST_VERSION }} |
| 110 | + default: true |
| 111 | + - name: Cargo publish check |
| 112 | + env: |
| 113 | + CRATES_IO_PUBLISH_TOKEN: ${{ secrets.CRATES_IO_PUBLISH_TOKEN }} |
| 114 | + run: | |
| 115 | + cargo login $CRATES_IO_PUBLISH_TOKEN |
| 116 | + cargo publish --dry-run |
| 117 | + - uses: actions/download-artifact@v2 |
| 118 | + with: |
| 119 | + name: antlr-tool |
| 120 | + - name: Create release |
| 121 | + id: create_release |
| 122 | + uses: actions/create-release@v1 |
| 123 | + env: |
| 124 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 125 | + with: |
| 126 | + tag_name: ${{ env.RELEASE_NAME }} |
| 127 | + release_name: ${{ env.RELEASE_NAME }} |
| 128 | + # make release a draft first in case `cargo publish` still fail |
| 129 | + draft: true |
| 130 | + prerelease: ${{ env.PRERELEASE }} |
| 131 | + - name: Upload Release Asset |
| 132 | + uses: actions/upload-release-asset@v1 |
| 133 | + env: |
| 134 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 135 | + with: |
| 136 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 137 | + asset_path: antlr4-4.8-2-SNAPSHOT-complete.jar |
| 138 | + asset_name: antlr4-4.8-2-SNAPSHOT-complete.jar |
| 139 | + asset_content_type: application/java-archive |
| 140 | + - name: Cargo publish |
| 141 | + run: cargo publish |
| 142 | + - name: Publish github release |
| 143 | + uses: actions/create-release@v1 |
| 144 | + env: |
| 145 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 146 | + with: |
| 147 | + release_name: ${{ env.RELEASE_NAME }} |
| 148 | + allowUpdates: true |
| 149 | + omitNameDuringUpdate: true |
| 150 | + omitPrereleaseDuringUpdate: true |
| 151 | + replacesArtifacts: false |
| 152 | + draft: false |
0 commit comments