-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (147 loc) · 4.78 KB
/
antlr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: CI
on:
push:
branches: [ master ]
pull_request:
branches:
- master
- v0.3
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_VERSION: nightly-2021-11-30
jobs:
tests-antlr:
name: ANTLR4 testsuite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: rrevenantt/antlr4
ref: rust-target
submodules: true
- run: |
git remote add signavio_fork [email protected]:signavio/antlr4rust.git
git fetch signavio_fork $GITHUB_REF
git checkout FETCH_HEAD
working-directory: runtime/Rust
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
default: true
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run : mvn -DskipTests install -q
- name : Maven tests
run: |
mvn test -Dtest=rust.* -q
rc=$?;
cat target/surefire-reports/*.dumpstream || true;
exit $rc
working-directory: runtime-testsuite
- uses: actions/upload-artifact@v2
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
with:
name: antlr-tool
path: tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar
tests-rust:
name: cargo test
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.check_ver.outputs.new_version }}
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
default: true
components: rustfmt
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Formatting
run: cargo fmt -- --check
- uses: actions/checkout@v2
if: ${{ github.event_name == 'push' }}
with:
# todo change to `fetch-depth: 2` and HEAD^
ref: ${{ github.event.before }}
path: base_branch
- name: check version bump
if: ${{ github.event_name == 'push' }}
id: check_ver
run: |
NEW_VER=$(cat Cargo.toml | sed -nE "s/^version.*\"([0-9a-z.\-]+)\".*$/\1/p")
BASE_VER=$(cat base_branch/Cargo.toml | sed -nE "s/^version.*\"([0-9a-z.\-]+)\".*$/\1/p")
if [[ "$NEW_VER" != "$BASE_VER" ]]; then
echo "::set-output name=new_version::$NEW_VER"
fi
publish:
runs-on: ubuntu-latest
if: |
success() && github.event_name == 'push'
&& needs.tests-rust.outputs.new_version != null
&& needs.tests-rust.outputs.new_version != ''
needs: [tests-rust,tests-antlr]
env:
RELEASE_NAME: ${{ format('antlr4-4.8-2-Rust{0}',needs.tests-rust.outputs.new_version) }}
PRERELEASE: ${{ contains(needs.tests-rust.outputs.new_version, '-') }}
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
default: true
- name: Cargo publish check
run: |
cargo publish --dry-run
- uses: actions/[email protected]
with:
name: antlr-tool
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_NAME }}
release_name: ${{ env.RELEASE_NAME }}
# make release a draft first in case `cargo publish` still fail
draft: true
prerelease: ${{ env.PRERELEASE }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: antlr4-4.8-2-SNAPSHOT-complete.jar
asset_name: antlr4-4.8-2-SNAPSHOT-complete.jar
asset_content_type: application/java-archive
- name: Cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_PUBLISH_TOKEN }}
run: |
git clean -f
cargo publish
- name: Publish github release
# todo use release-drafter/release-drafter@v5
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.release_id }}