-
Notifications
You must be signed in to change notification settings - Fork 5
161 lines (143 loc) · 5.29 KB
/
Copy pathrust_antlr.yml
File metadata and controls
161 lines (143 loc) · 5.29 KB
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
155
156
157
158
159
160
161
name: Publish Rust ANTLR
run-name: Publish Rust ANTLR for Version ${{ inputs.substrait_version }}
concurrency:
group: rust-antlr
cancel-in-progress: false
on:
workflow_call:
inputs:
substrait_version:
description: Substrait version to generate ANTLR parsers for
required: true
type: string
alpha:
description: Publish an auto-incrementing alpha pre-release (-alpha, -alpha.1, ...)
required: false
default: true
type: boolean
workflow_dispatch:
inputs:
substrait_version:
description: Substrait version to generate ANTLR parsers for
required: true
type: string
alpha:
description: Publish an auto-incrementing alpha pre-release (-alpha, -alpha.1, ...)
required: false
default: true
type: boolean
env:
SUBSTRAIT_VERSION: ${{ inputs.substrait_version }}
jobs:
rust-antlr-prechecks:
runs-on: ubuntu-latest
outputs:
publish_version: ${{ steps.resolve.outputs.version }}
tag_name: ${{ steps.resolve.outputs.tag_name }}
tag_exists: ${{ steps.check-tag.outputs.exists }}
artifact_exists: ${{ steps.check-artifact.outputs.exists }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Resolve Publish Version
id: resolve
run: |
if [ "${{ inputs.alpha }}" = "true" ]; then
VERSION=$(./scripts/rust/next_alpha_version.sh substrait-antlr "$SUBSTRAIT_VERSION")
else
VERSION="${SUBSTRAIT_VERSION#v}"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag_name=rust/substrait-antlr/v$VERSION" >> "$GITHUB_OUTPUT"
- name: Check Tag Existence
id: check-tag
run: |
EXISTS=$(./scripts/tag_exists.sh "${{ steps.resolve.outputs.tag_name }}")
echo "exists=$EXISTS" >> "$GITHUB_OUTPUT"
- name: Check Artifact Existence on crates.io
id: check-artifact
run: |
EXISTS=$(./scripts/rust/crate_exists.sh substrait-antlr "${{ steps.resolve.outputs.version }}")
echo "exists=$EXISTS" >> "$GITHUB_OUTPUT"
rust-antlr-generate:
runs-on: ubuntu-latest
needs: rust-antlr-prechecks
steps:
- name: Generate GitHub App Token for Pushing Tags
uses: actions/create-github-app-token@v3
id: app-token
with:
client-id: ${{ secrets.PACKAGER_CLIENT_ID }}
private-key: ${{ secrets.PACKAGER_KEY }}
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Configure GitHub User
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
git config --global url."https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/".insteadOf https://github.com/
- name: Checkout substrait-packaging
uses: actions/checkout@v7
with:
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 0
persist-credentials: false
- name: Install pixi
uses: prefix-dev/setup-pixi@v0.10.0
with:
pixi-version: v0.62.2
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Attach and Commit substrait Repo
run: ./scripts/attach_subtree.sh
- name: Generate ANTLR Parsers
run: pixi run rust-generate-antlr
- name: Set Version
run: ./scripts/rust/set_version.sh rust/substrait-antlr "${{ needs.rust-antlr-prechecks.outputs.publish_version }}"
- name: Build and Test
working-directory: rust/substrait-antlr
run: |
cargo build
cargo test
- name: Commit Generated Code
run: |
git add rust/substrait-antlr
git commit -m "Generated ANTLR parsers for Substrait version $SUBSTRAIT_VERSION"
- name: Tag and Push Generated Code
if: needs.rust-antlr-prechecks.outputs.tag_exists == 'false'
env:
TAG_NAME: ${{ needs.rust-antlr-prechecks.outputs.tag_name }}
run: |
git tag -a "$TAG_NAME" -m "$TAG_NAME"
git push origin "$TAG_NAME"
rust-antlr-publish:
runs-on: ubuntu-latest
needs: [rust-antlr-prechecks, rust-antlr-generate]
if: needs.rust-antlr-prechecks.outputs.artifact_exists == 'false'
environment: crates-io
permissions:
contents: read
id-token: write
defaults:
run:
working-directory: rust/substrait-antlr
steps:
- name: Checkout substrait-antlr
uses: actions/checkout@v7
with:
ref: ${{ needs.rust-antlr-prechecks.outputs.tag_name }}
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Authenticate with crates.io
uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish