Skip to content

Commit aa17242

Browse files
committed
Update release.yml
1 parent 4dedb43 commit aa17242

1 file changed

Lines changed: 30 additions & 117 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,65 @@
1-
name: Release
1+
name: Publish to crates.io
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
74
workflow_dispatch:
85
inputs:
9-
version:
10-
description: 'Version to release (e.g., 0.1.0)'
11-
required: true
12-
type: string
6+
dry_run:
7+
description: 'Dry run only (no publish)'
8+
required: false
9+
default: true
10+
type: boolean
1311

1412
env:
1513
CARGO_TERM_COLOR: always
1614

1715
jobs:
18-
build-release:
19-
name: Build ${{ matrix.target }}
16+
publish:
17+
name: Publish
2018
runs-on: windows-latest
2119
defaults:
2220
run:
2321
working-directory: ./ProcessGhosting
24-
strategy:
25-
matrix:
26-
target:
27-
- x86_64-pc-windows-msvc
28-
- i686-pc-windows-msvc
2922
steps:
3023
- name: Checkout
3124
uses: actions/checkout@v4
3225

3326
- name: Install Rust
3427
uses: dtolnay/rust-toolchain@stable
35-
with:
36-
targets: ${{ matrix.target }}
3728

3829
- name: Cache
3930
uses: Swatinem/rust-cache@v2
4031
with:
4132
workspaces: ProcessGhosting
4233

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-
4934
- name: Get version
5035
id: version
5136
shell: bash
5237
run: |
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
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"
5843
59-
- name: Package
60-
shell: pwsh
61-
working-directory: ./ProcessGhosting
44+
- name: Verify package
6245
run: |
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
46+
cargo package --list
47+
cargo package
10748
108-
- name: Download artifacts
109-
uses: actions/download-artifact@v4
110-
with:
111-
path: artifacts
112-
pattern: release-*
113-
merge-multiple: true
49+
- name: Dry run
50+
if: ${{ inputs.dry_run }}
51+
run: cargo publish --dry-run
11452

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
53+
- name: Publish to crates.io
54+
if: ${{ !inputs.dry_run }}
15055
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}
15156
env:
152-
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
57+
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

Comments
 (0)