Skip to content

Commit 7bc6485

Browse files
authored
Merge branch 'main' into py-wheels
2 parents 12b2181 + 5e0edc6 commit 7bc6485

File tree

107 files changed

+4530
-2710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+4530
-2710
lines changed

.github/workflows/build.yml

Lines changed: 142 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,113 @@
1-
name: Build CLI binaries
1+
name: Rust
2+
23
on:
34
- push
5+
- pull_request
6+
- merge_group
7+
48
permissions:
5-
contents: write
9+
contents: read
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
GH_TOKEN: ${{ github.token }}
14+
PROJECT_NAME: diffenator3
15+
CARGO_PUBLISH_ARGS: "-p ttj -p diffenator3-lib -p diffenator3 -p diff3proof"
16+
CRATE_PATTERN: "ttj|diffenator3(-lib)?|diff3proof"
17+
618
jobs:
7-
build-and-upload:
8-
name: Build and upload
9-
runs-on: ${{ matrix.os }}
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
submodules: recursive
26+
- uses: actions-rust-lang/setup-rust-toolchain@v1
27+
name: Set up Rust for caching
28+
- name: Install protoc for lang repo
29+
uses: arduino/setup-protoc@v3
30+
with:
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Build
33+
run: cargo build
34+
# - name: Run tests
35+
# run: |
36+
# cargo test --verbose --workspace
37+
# pip install maturin pytest
38+
# cd shaperglot-py
39+
# maturin build
40+
# pip install ../target/wheels/shaperglot*.whl
41+
# #pytest --verbose
42+
43+
formatting:
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
submodules: recursive
50+
- uses: actions-rust-lang/setup-rust-toolchain@v1
51+
name: Set up Rust for caching
52+
- name: Install protoc for lang repo
53+
uses: arduino/setup-protoc@v3
54+
with:
55+
repo-token: ${{ secrets.GITHUB_TOKEN }}
56+
- name: Lint for formatting
57+
run: cargo fmt --all -- --check
58+
lint:
59+
runs-on: ubuntu-latest
1060

61+
steps:
62+
- uses: actions/checkout@v4
63+
with:
64+
submodules: recursive
65+
- uses: actions-rust-lang/setup-rust-toolchain@v1
66+
name: Set up Rust for caching
67+
- name: Install protoc for lang repo
68+
uses: arduino/setup-protoc@v3
69+
with:
70+
repo-token: ${{ secrets.GITHUB_TOKEN }}
71+
- name: Lint for warnings
72+
run: cargo clippy --all-targets --all-features -- -D warnings
73+
74+
check-for-release:
75+
name: Create release if needed
76+
runs-on: ubuntu-latest
77+
permissions:
78+
contents: write
79+
id-token: write
80+
steps:
81+
- uses: actions/checkout@v3
82+
- if: contains(github.ref, 'refs/tags/v')
83+
run:
84+
python3 scripts/check_versions.py
85+
env:
86+
CRATE_PATTERN: ${{ env.CRATE_PATTERN }}
87+
- if: contains(github.ref, 'refs/tags/v')
88+
name: Check for release
89+
id: create_release
90+
run: |
91+
if ! gh release view ${{ github.ref_name }}; then
92+
git show -s --format=%B ${{ github.ref_name }} | tail -n +4 | gh release create ${{ github.ref_name }} -t ${{ github.ref_name }} -F -
93+
fi
94+
95+
deploy-binaries:
96+
name: Build and upload binaries
97+
permissions:
98+
contents: write
99+
id-token: write
100+
needs: [build, check-for-release]
101+
runs-on: ${{ matrix.os.os }}
102+
# Only build on main or tag
103+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
11104
strategy:
105+
fail-fast: false
12106
matrix:
13-
include:
107+
os:
14108
- build: linux
15-
os: ubuntu-latest
16-
target: x86_64-unknown-linux-musl
109+
os: ubuntu-22.04
110+
target: x86_64-unknown-linux-gnu
17111

18112
- build: macos
19113
os: macos-latest
@@ -26,27 +120,31 @@ jobs:
26120
- build: windows-gnu
27121
os: windows-latest
28122
target: x86_64-pc-windows-gnu
123+
# python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
29124

30125
steps:
31126
- name: Checkout
32127
uses: actions/checkout@v4
128+
with:
129+
submodules: recursive
33130
- name: Install Rust
34131
uses: actions-rust-lang/setup-rust-toolchain@v1
35132
with:
36-
target: ${{ matrix.target }}
133+
target: ${{ matrix.os.target }}
134+
cache-key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
37135
- name: Install protoc for lang repo
38136
uses: arduino/setup-protoc@v3
39137
with:
40-
repo-token: ${{ secrets.GITHUB_TOKEN }}
41-
- name: Build diffenator3/diff3proof
42-
run: cargo build --verbose --release --target ${{ matrix.target }}
138+
repo-token: ${{ secrets.GITHUB_TOKEN }}
139+
- name: Build
140+
run: cargo build --verbose --release --target ${{ matrix.os.target }}
43141
- name: Decide on our version name (tag or "dev")
44142
id: version
45143
shell: bash
46144
run: |
47145
if [ -n "$GITHUB_REF" ]; then
48-
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
49-
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
146+
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
147+
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
50148
else
51149
echo "VERSION=dev" >> $GITHUB_ENV
52150
fi
@@ -56,26 +154,44 @@ jobs:
56154
- name: Build archive
57155
shell: bash
58156
run: |
59-
dirname="diffenator3-${{ env.VERSION }}-${{ matrix.target }}"
157+
# dirname="${{env.PROJECT_NAME}}-${{ env.VERSION }}-${{ matrix.os.target }}-py${{ matrix.python }}"
158+
dirname="${{env.PROJECT_NAME}}-${{ env.VERSION }}-${{ matrix.os.target }}"
60159
mkdir "$dirname"
61-
if [ "${{ matrix.os }}" = "windows-latest" ]; then
62-
mv "target/${{ matrix.target }}/release/"*.exe "$dirname"
160+
if [ "${{ matrix.os.os }}" = "windows-latest" ]; then
161+
mv "target/${{ matrix.os.target }}/release/"*.exe "$dirname"
63162
7z a "$dirname.zip" "$dirname"
64163
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
65164
else
66-
mv "target/${{ matrix.target }}/release/diffenator3" "$dirname"
67-
mv "target/${{ matrix.target }}/release/diff3proof" "$dirname"
165+
mv "target/${{ matrix.os.target }}/release/${{env.PROJECT_NAME}}" "$dirname"
68166
tar -czf "$dirname.tar.gz" "$dirname"
69167
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
70168
fi
71169
- uses: actions/upload-artifact@v4
72170
with:
73171
name: ${{ env.ASSET }}
74172
path: ${{ env.ASSET }}
75-
- if: contains(github.ref, 'refs/tags/')
76-
name: Create a release
77-
uses: softprops/action-gh-release@v1
78-
with:
79-
files: ${{ env.ASSET }}
80-
tag_name: ${{ env.VERSION }}
81-
token: ${{ secrets.GITHUB_TOKEN }}
173+
- if: contains(github.ref, 'refs/tags/v')
174+
name: Add artefact to release
175+
env:
176+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177+
run: gh release upload v${{ env.VERSION }} ${{ env.ASSET }}
178+
179+
publish-crate:
180+
needs: deploy-binaries
181+
runs-on: ubuntu-latest
182+
if: contains(github.ref, 'refs/tags/v')
183+
184+
steps:
185+
- uses: actions/checkout@v3
186+
- uses: actions-rs/toolchain@v1
187+
with:
188+
toolchain: stable
189+
override: true
190+
- name: Install protoc for lang repo
191+
uses: arduino/setup-protoc@v3
192+
with:
193+
repo-token: ${{ secrets.GITHUB_TOKEN }}
194+
- run:
195+
cargo publish ${{ env.CARGO_PUBLISH_ARGS }} --no-verify
196+
env:
197+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 commit comments

Comments
 (0)