Skip to content

Commit 110788d

Browse files
ci: fix workflows and align test globs with canonical workspace
- release.yml: replace archived actions/create-release@v1 and upload-release-asset@v1 with softprops/action-gh-release@v2; add contents:write permission; download all artifacts via merge-multiple. - publish.yml: skip cargo publish if version already exists on crates.io; switch to CARGO_REGISTRY_TOKEN env var; add --locked. - ci.yml: drop redundant build-tag job (now lives in release.yml); add --locked to check/clippy/build/test. - test_code_writer_mode: canonicalize workspace path so glob assertions match BashState on macOS (/var → /private/var symlink).
1 parent ab704a1 commit 110788d

3 files changed

Lines changed: 74 additions & 101 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
name: Rust CI
1616
runs-on: ${{ matrix.os }}
1717
strategy:
18+
fail-fast: false
1819
matrix:
1920
os: [ ubuntu-latest, macos-latest ]
2021
steps:
@@ -27,64 +28,20 @@ jobs:
2728

2829
- name: Rust Cache
2930
uses: Swatinem/rust-cache@v2
31+
with:
32+
key: ${{ matrix.os }}-ci
3033

3134
- name: Check
32-
run: cargo check --all-features
35+
run: cargo check --all-features --locked
3336

3437
- name: Format
3538
run: cargo fmt --all -- --check
3639

3740
- name: Clippy
38-
run: cargo clippy --all-features -- -W clippy::all -A clippy::missing_docs_in_private_items -A clippy::pedantic
41+
run: cargo clippy --all-features --locked -- -W clippy::all -A clippy::missing_docs_in_private_items -A clippy::pedantic
3942

4043
- name: Build
41-
run: cargo build --all-features
44+
run: cargo build --all-features --locked
4245

4346
- name: Test
44-
run: cargo test --all-features
45-
46-
build-tag:
47-
name: Build Tag Release
48-
# Only run this job when a tag is pushed
49-
if: startsWith(github.ref, 'refs/tags/v')
50-
runs-on: ${{ matrix.os }}
51-
strategy:
52-
matrix:
53-
os: [ ubuntu-latest, macos-latest, windows-latest ]
54-
include:
55-
- os: ubuntu-latest
56-
artifact_name: winx
57-
asset_name: winx-linux-amd64
58-
- os: macos-latest
59-
artifact_name: winx
60-
asset_name: winx-macos-amd64
61-
- os: windows-latest
62-
artifact_name: winx.exe
63-
asset_name: winx-windows-amd64.exe
64-
steps:
65-
- uses: actions/checkout@v6
66-
67-
- name: Setup Rust
68-
uses: dtolnay/rust-toolchain@stable
69-
70-
- name: Rust Cache
71-
uses: Swatinem/rust-cache@v2
72-
73-
- name: Build release binary
74-
run: cargo build --release
75-
76-
- name: Rename binary
77-
shell: bash
78-
run: |
79-
if [ "${{ matrix.os }}" = "windows-latest" ]; then
80-
cp target/release/winx-code-agent.exe ${{ matrix.artifact_name }}
81-
else
82-
cp target/release/winx-code-agent ${{ matrix.artifact_name }}
83-
fi
84-
85-
- name: Upload build artifact
86-
uses: actions/upload-artifact@v6
87-
with:
88-
name: ${{ matrix.asset_name }}
89-
path: ${{ matrix.artifact_name }}
90-
retention-days: 5
47+
run: cargo test --all-features --locked

.github/workflows/publish.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,36 @@ jobs:
1515
- name: Setup Rust
1616
uses: dtolnay/rust-toolchain@stable
1717

18-
- name: Verify tag version matches Cargo.toml
18+
- name: Rust Cache
19+
uses: Swatinem/rust-cache@v2
20+
with:
21+
key: publish
22+
23+
- name: Verify tag matches Cargo.toml
1924
run: |
20-
# Extract version from Cargo.toml
21-
CARGO_VERSION=$(grep -m1 'version =' Cargo.toml | cut -d '"' -f2)
22-
# Extract version from git tag
23-
TAG_VERSION=${GITHUB_REF#refs/tags/v}
24-
25-
# Check if versions match
25+
CARGO_VERSION=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2)
26+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
2627
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
27-
echo "Version mismatch: Cargo.toml version ($CARGO_VERSION) does not match tag version ($TAG_VERSION)"
28+
echo "::error::Cargo.toml version ($CARGO_VERSION) != tag ($TAG_VERSION)"
2829
exit 1
2930
fi
30-
31-
echo "Version $CARGO_VERSION matches tag $TAG_VERSION"
31+
echo "version=$CARGO_VERSION" >> "$GITHUB_ENV"
3232
33-
- name: Cargo login
34-
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
33+
- name: Skip if version already on crates.io
34+
id: check
35+
run: |
36+
status=$(curl -sf -A "winx-ci/1.0" \
37+
"https://crates.io/api/v1/crates/winx-code-agent/${{ env.version }}" \
38+
-o /dev/null -w "%{http_code}" || true)
39+
if [ "$status" = "200" ]; then
40+
echo "winx-code-agent ${{ env.version }} already exists on crates.io — skipping"
41+
echo "skip=true" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "skip=false" >> "$GITHUB_OUTPUT"
44+
fi
3545
3646
- name: Cargo publish
37-
run: cargo publish
47+
if: steps.check.outputs.skip != 'true'
48+
env:
49+
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
50+
run: cargo publish --locked

.github/workflows/release.yml

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,25 @@ on:
55
tags:
66
- 'v*'
77

8-
jobs:
9-
create-release:
10-
name: Create GitHub Release
11-
runs-on: ubuntu-latest
12-
outputs:
13-
upload_url: ${{ steps.create_release.outputs.upload_url }}
14-
steps:
15-
- name: Create Release
16-
id: create_release
17-
uses: actions/create-release@v1
18-
env:
19-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20-
with:
21-
tag_name: ${{ github.ref }}
22-
release_name: Release ${{ github.ref_name }}
23-
draft: false
24-
prerelease: false
8+
permissions:
9+
contents: write
2510

11+
jobs:
2612
build:
2713
name: Build Release
28-
needs: create-release
2914
runs-on: ${{ matrix.os }}
3015
strategy:
16+
fail-fast: false
3117
matrix:
32-
os: [ ubuntu-latest, macos-latest, windows-latest ]
3318
include:
3419
- os: ubuntu-latest
35-
artifact_name: winx
20+
artifact_name: winx-code-agent
3621
asset_name: winx-linux-amd64
3722
- os: macos-latest
38-
artifact_name: winx
39-
asset_name: winx-macos-amd64
23+
artifact_name: winx-code-agent
24+
asset_name: winx-macos-arm64
4025
- os: windows-latest
41-
artifact_name: winx.exe
26+
artifact_name: winx-code-agent.exe
4227
asset_name: winx-windows-amd64.exe
4328

4429
steps:
@@ -49,25 +34,43 @@ jobs:
4934

5035
- name: Rust Cache
5136
uses: Swatinem/rust-cache@v2
37+
with:
38+
key: ${{ matrix.os }}-release
5239

5340
- name: Build release binary
54-
run: cargo build --release
41+
run: cargo build --release --locked
5542

56-
- name: Rename binary
43+
- name: Stage artifact
5744
shell: bash
5845
run: |
59-
if [ "${{ matrix.os }}" = "windows-latest" ]; then
60-
cp target/release/winx-code-agent.exe ${{ matrix.artifact_name }}
61-
else
62-
cp target/release/winx-code-agent ${{ matrix.artifact_name }}
63-
fi
46+
mkdir -p dist
47+
cp "target/release/${{ matrix.artifact_name }}" "dist/${{ matrix.asset_name }}"
48+
49+
- name: Upload artifact
50+
uses: actions/upload-artifact@v6
51+
with:
52+
name: ${{ matrix.asset_name }}
53+
path: dist/${{ matrix.asset_name }}
54+
retention-days: 5
55+
56+
release:
57+
name: Publish GitHub Release
58+
needs: build
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v6
62+
63+
- name: Download all artifacts
64+
uses: actions/download-artifact@v6
65+
with:
66+
path: dist
67+
merge-multiple: true
6468

65-
- name: Upload release asset
66-
uses: actions/upload-release-asset@v1
67-
env:
68-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
- name: Publish release
70+
uses: softprops/action-gh-release@v2
6971
with:
70-
upload_url: ${{ needs.create-release.outputs.upload_url }}
71-
asset_path: ./${{ matrix.artifact_name }}
72-
asset_name: ${{ matrix.asset_name }}
73-
asset_content_type: application/octet-stream
72+
tag_name: ${{ github.ref_name }}
73+
name: ${{ github.ref_name }}
74+
generate_release_notes: true
75+
fail_on_unmatched_files: true
76+
files: dist/*

0 commit comments

Comments
 (0)