1- name : Publish to crates.io
1+ name : Release
22
33on :
4+ push :
5+ tags :
6+ - ' v*'
47 workflow_dispatch :
58 inputs :
6- dry_run :
7- description : ' Dry run only (no publish)'
8- required : false
9- default : true
10- type : boolean
9+ version :
10+ description : ' Version to release (e.g., 0.1.0)'
11+ required : true
12+ type : string
1113
1214env :
1315 CARGO_TERM_COLOR : always
1416
1517jobs :
16- publish :
17- name : Publish
18+ build-release :
19+ name : Build ${{ matrix.target }}
1820 runs-on : windows-latest
1921 defaults :
2022 run :
2123 working-directory : ./ProcessGhosting
24+ strategy :
25+ matrix :
26+ target :
27+ - x86_64-pc-windows-msvc
28+ - i686-pc-windows-msvc
2229 steps :
2330 - name : Checkout
2431 uses : actions/checkout@v4
2532
2633 - name : Install Rust
2734 uses : dtolnay/rust-toolchain@stable
35+ with :
36+ targets : ${{ matrix.target }}
2837
2938 - name : Cache
3039 uses : Swatinem/rust-cache@v2
3140 with :
3241 workspaces : ProcessGhosting
3342
43+ - name : Build release
44+ run : cargo build --release --target ${{ matrix.target }}
45+
46+ - name : Build examples
47+ run : cargo build --examples --release --target ${{ matrix.target }}
48+
3449 - name : Get version
3550 id : version
3651 shell : bash
3752 run : |
38- # Generate Cargo.lock for cargo pkgid
39- cargo generate-lockfile
40- VERSION=$(cargo pkgid | sed 's/.*#//')
41- echo "VERSION=$VERSION " >> $GITHUB_OUTPUT
42- echo "Publishing version: $VERSION"
53+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
54+ echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
55+ else
56+ echo "VERSION=${GITHUB_REF#refs/tags/v} " >> $GITHUB_OUTPUT
57+ fi
4358
44- - name : Verify package
59+ - name : Package
60+ shell : pwsh
61+ working-directory : ./ProcessGhosting
4562 run : |
46- cargo package --list
47- cargo package
63+ $target = "${{ matrix.target }}"
64+ $version = "${{ steps.version.outputs.VERSION }}"
65+ $name = "ProcessGhosting-$version-$target"
66+
67+ New-Item -ItemType Directory -Path $name -Force
68+
69+ # Copy library files
70+ Copy-Item "target/$target/release/process_ghosting.dll" "$name/" -ErrorAction SilentlyContinue
71+ Copy-Item "target/$target/release/process_ghosting.lib" "$name/" -ErrorAction SilentlyContinue
72+ Copy-Item "target/$target/release/process_ghosting.d" "$name/" -ErrorAction SilentlyContinue
73+
74+ # Copy examples
75+ $examplesDir = "$name/examples"
76+ New-Item -ItemType Directory -Path $examplesDir -Force
77+ Get-ChildItem "target/$target/release/examples/*.exe" | Copy-Item -Destination $examplesDir -ErrorAction SilentlyContinue
78+
79+ # Copy docs
80+ Copy-Item "README.md" "$name/" -ErrorAction SilentlyContinue
81+ Copy-Item "LICENSE" "$name/" -ErrorAction SilentlyContinue
82+
83+ # Create zip
84+ Compress-Archive -Path $name -DestinationPath "$name.zip"
85+
86+ # Create checksum
87+ $hash = (Get-FileHash "$name.zip" -Algorithm SHA256).Hash
88+ "$hash $name.zip" | Out-File -FilePath "$name.zip.sha256" -Encoding utf8
89+
90+ - name : Upload artifact
91+ uses : actions/upload-artifact@v4
92+ with :
93+ name : release-${{ matrix.target }}
94+ path : |
95+ ProcessGhosting/*.zip
96+ ProcessGhosting/*.sha256
97+
98+ publish-github :
99+ name : Publish GitHub Release
100+ runs-on : ubuntu-latest
101+ needs : build-release
102+ permissions :
103+ contents : write
104+ steps :
105+ - name : Checkout
106+ uses : actions/checkout@v4
48107
49- - name : Dry run
50- if : ${{ inputs.dry_run }}
51- run : cargo publish --dry-run
108+ - name : Download artifacts
109+ uses : actions/download-artifact@v4
110+ with :
111+ path : artifacts
112+ pattern : release-*
113+ merge-multiple : true
52114
53- - name : Publish to crates.io
54- if : ${{ !inputs.dry_run }}
115+ - name : Create Release
116+ uses : softprops/action-gh-release@v1
117+ with :
118+ files : |
119+ artifacts/*.zip
120+ artifacts/*.sha256
121+ generate_release_notes : true
122+ draft : false
123+ prerelease : ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
124+ env :
125+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
126+
127+ publish-crates :
128+ name : Publish to crates.io
129+ runs-on : windows-latest
130+ needs : build-release
131+ defaults :
132+ run :
133+ working-directory : ./ProcessGhosting
134+ steps :
135+ - name : Checkout
136+ uses : actions/checkout@v4
137+
138+ - name : Install Rust
139+ uses : dtolnay/rust-toolchain@stable
140+
141+ - name : Cache
142+ uses : Swatinem/rust-cache@v2
143+ with :
144+ workspaces : ProcessGhosting
145+
146+ - name : Verify package
147+ run : cargo package --list
148+
149+ - name : Publish
55150 run : cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}
56151 env :
57152 CRATES_IO_TOKEN : ${{ secrets.CRATES_IO_TOKEN }}
58-
59- - name : Summary
60- run : |
61- echo "## Publish Summary" >> $GITHUB_STEP_SUMMARY
62- echo "" >> $GITHUB_STEP_SUMMARY
63- echo "- **Version**: ${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
64- echo "- **Dry Run**: ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY
65- echo "- **Crate**: [ProcessGhosting](https://crates.io/crates/ProcessGhosting)" >> $GITHUB_STEP_SUMMARY
0 commit comments