Skip to content

Commit 8c374a5

Browse files
authored
Release 0.1 beta.2 (#19)
1 parent 203f0b0 commit 8c374a5

File tree

13 files changed

+426
-687
lines changed

13 files changed

+426
-687
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,71 @@ jobs:
5656

5757
- name: Lint with Clippy (Stable Only)
5858
if: matrix.toolchain == 'stable'
59-
run: cargo clippy --all-targets --all-features
59+
run: cargo clippy --all-targets --features="runtime-features"
6060

6161
- name: Check Code Formatting (Stable Only)
6262
if: matrix.toolchain == 'stable'
6363
run: cargo fmt -- --check
6464

65-
- name: Build the Project
66-
run: cargo build --verbose
65+
- name: Build the Project with nuget
66+
run: cargo build --features="runtime-features" --verbose
67+
68+
- name: Build the Project without nuget
69+
run: cargo build --all-features --verbose
6770

6871
- name: Run Tests
69-
run: cargo test --verbose
72+
run: cargo test --features="runtime-features" --verbose
7073

7174
- name: Generate Documentation (${{ matrix.DOCTYPE }}, ${{ matrix.toolchain }})
72-
run: cargo doc --no-deps --all-features
75+
run: cargo doc --no-deps --features="runtime-features"
7376

7477
- name: Install and Run Security Audit (Nightly Only)
7578
if: matrix.toolchain == 'nightly'
7679
run: |
7780
cargo install cargo-audit
7881
cargo audit
82+
83+
cross-compile:
84+
name: "Cross Compilation for Windows targets on Linux (x86_64 only)"
85+
runs-on: ubuntu-latest
86+
strategy:
87+
matrix:
88+
target:
89+
- triple: "x86_64-pc-windows-gnu"
90+
linker: "x86_64-w64-mingw32-gcc"
91+
ar: "x86_64-w64-mingw32-gcc-ar"
92+
- triple: "x86_64-pc-windows-gnullvm"
93+
linker: "x86_64-w64-mingw32-gcc"
94+
ar: "x86_64-w64-mingw32-gcc-ar"
95+
env:
96+
CARGO_TERM_COLOR: always
97+
RUSTFLAGS: -D warnings
98+
RUST_BACKTRACE: 1
99+
steps:
100+
- name: Checkout Repository
101+
uses: actions/checkout@v4
102+
103+
- name: Install Rust stable toolchain and add target
104+
run: |
105+
rustup update stable
106+
rustup default stable
107+
rustup target add ${{ matrix.target.triple }}
108+
109+
- name: Install cross-compilation toolchain
110+
run: |
111+
sudo apt-get update
112+
sudo apt-get install -y clang llvm mingw-w64
113+
114+
- name: Set up environment for Windows cross-compilation
115+
shell: bash
116+
run: |
117+
var_name=$(echo "${{ matrix.target.triple }}" | tr '-' '_' | tr '[:lower:]' '[:upper:]')
118+
echo "Setting CARGO_TARGET_${var_name}_LINKER=${{ matrix.target.linker }}"
119+
echo "CARGO_TARGET_${var_name}_LINKER=${{ matrix.target.linker }}" >> $GITHUB_ENV
120+
echo "CARGO_TARGET_${var_name}_AR=${{ matrix.target.ar }}" >> $GITHUB_ENV
121+
122+
- name: Build Project for target ${{ matrix.target.triple }}
123+
run: cargo build --target=${{ matrix.target.triple }} --features=no-nuget --release
124+
125+
- name: Run doc
126+
run: cargo doc --target=${{ matrix.target.triple }} --no-deps --all-features

.github/workflows/deploy.yml

Lines changed: 0 additions & 124 deletions
This file was deleted.
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: Tag on Merge and Deploy
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
push:
8+
tags:
9+
- "v*"
10+
11+
permissions:
12+
contents: write
13+
packages: write
14+
15+
jobs:
16+
determine-tag:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
tag_name: ${{ steps.determine.outputs.tag }}
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Determine tag to use
27+
id: determine
28+
shell: bash
29+
run: |
30+
echo "Event: ${GITHUB_EVENT_NAME}"
31+
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
32+
if [ "${{ github.event.pull_request.merged }}" = "true" ]; then
33+
echo "PR merged, creating tag..."
34+
branch="${GITHUB_HEAD_REF}"
35+
# S'assurer que la branche commence par 'release/'
36+
if [[ "$branch" != release/* ]]; then
37+
echo "Error: Branch '$branch' does not start with 'release/'"
38+
exit 1
39+
fi
40+
version="${branch#release/}"
41+
if [ -z "$version" ]; then
42+
echo "Error: Extracted version is empty."
43+
exit 1
44+
fi
45+
tag="v${version}"
46+
echo "Creating tag: $tag"
47+
git config user.name "GitHub Actions"
48+
git config user.email "actions@github.com"
49+
git tag "$tag" -a -m "Release version $version"
50+
git push origin "$tag"
51+
echo "tag=$tag" >> $GITHUB_OUTPUT
52+
else
53+
echo "PR not merged. Doing nothing."
54+
# On n'émet pas de tag, ainsi le job suivant sera ignoré.
55+
echo "tag=" >> $GITHUB_OUTPUT
56+
exit 0
57+
fi
58+
elif [ "${GITHUB_EVENT_NAME}" = "push" ]; then
59+
echo "Push event detected."
60+
tag="${GITHUB_REF#refs/tags/}"
61+
if [ -z "$tag" ]; then
62+
echo "Error: TAG value from push event is empty."
63+
exit 1
64+
fi
65+
echo "Using pushed tag: $tag"
66+
echo "tag=$tag" >> $GITHUB_OUTPUT
67+
else
68+
echo "Error: Unsupported event '${GITHUB_EVENT_NAME}'."
69+
exit 1
70+
fi
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
validate-and-release:
75+
# Le job de déploiement ne s'exécute que si un tag a été déterminé
76+
if: ${{ needs.determine-tag.outputs.tag_name != '' }}
77+
needs: determine-tag
78+
runs-on: windows-latest
79+
env:
80+
# Le tag est accessible dans toutes les étapes via la variable TAG_NAME
81+
TAG_NAME: ${{ needs.determine-tag.outputs.tag_name }}
82+
CARGO_TERM_COLOR: always
83+
RUSTFLAGS: -D warnings
84+
steps:
85+
- name: Validate TAG_NAME presence
86+
shell: pwsh
87+
run: |
88+
if (-not $env:TAG_NAME -or $env:TAG_NAME -eq "") {
89+
Write-Error "TAG_NAME is empty. Aborting deployment."
90+
exit 1
91+
} else {
92+
Write-Host "TAG_NAME is set to $env:TAG_NAME."
93+
}
94+
95+
- name: Checkout repository
96+
uses: actions/checkout@v4
97+
98+
- name: Cache Cargo Registry
99+
uses: actions/cache@v3
100+
with:
101+
path: ~/.cargo/registry
102+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
103+
restore-keys: ${{ runner.os }}-cargo-registry-
104+
105+
- name: Cache Cargo Git Index
106+
uses: actions/cache@v3
107+
with:
108+
path: ~/.cargo/git
109+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
110+
restore-keys: ${{ runner.os }}-cargo-index-
111+
112+
- name: Install Rust
113+
shell: pwsh
114+
run: rustup update stable && rustup default stable
115+
116+
- name: Install PSSemVer
117+
shell: pwsh
118+
run: |
119+
try {
120+
Import-Module -Name PSSemVer -ErrorAction Stop
121+
} catch {
122+
Write-Host "Installing PSSemVer module..."
123+
Install-Module -Name PSSemVer -Scope CurrentUser -Force -ErrorAction Stop
124+
Import-Module -Name PSSemVer -ErrorAction Stop
125+
}
126+
127+
- name: Validate tag with PSSemVer
128+
id: validate
129+
shell: pwsh
130+
run: |
131+
$tagName = "${env:TAG_NAME}"
132+
Import-Module -Name PSSemVer -ErrorAction Stop
133+
try {
134+
$rawVersion = $tagName -replace '^v', ''
135+
$Version = [PSSemVer]::Parse($rawVersion)
136+
$prereleaseValue = ($Version.Prerelease -ne $null).ToString().ToLower()
137+
echo "prerelease=$prereleaseValue" >> $env:GITHUB_ENV
138+
if (-not [string]::IsNullOrEmpty($Version.BuildMetadata)) {
139+
echo "nuget_version=$($Version.BuildMetadata)" >> $env:GITHUB_ENV
140+
} else {
141+
Write-Host "No metadata found. Using version without metadata for NuGet."
142+
echo "nuget_version=$rawVersion" >> $env:GITHUB_ENV
143+
}
144+
} catch {
145+
Write-Error "Invalid semantic version in tag: $tagName"
146+
exit 1
147+
}
148+
continue-on-error: false
149+
150+
- name: Run Cargo Publish in Dry-Run Mode
151+
run: cargo publish --dry-run
152+
153+
- name: Create GitHub Release
154+
id: release
155+
uses: softprops/action-gh-release@v2
156+
with:
157+
tag_name: ${{ env.TAG_NAME }}
158+
name: ${{ env.prerelease == 'true' && 'Prerelease' || 'Release' }} ${{ env.TAG_NAME }}
159+
body: |
160+
This is a **${{ env.prerelease == 'true' && 'prerelease' || 'release' }}** release of **${{ github.repository }}**.
161+
- The crate is available on [Crates.io](https://crates.io/crates/${{ github.repository.name }}).
162+
- This version provides bindings for **WSLPluginAPI v${{ env.nuget_version }}**, available on [NuGet](https://www.nuget.org/packages/Microsoft.WSL.PluginApi/${{ env.nuget_version }}).
163+
prerelease: ${{ env.prerelease == 'true' }}
164+
165+
- name: Cargo Publish on crates.io
166+
run: cargo publish
167+
env:
168+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/release-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
Write-Error "❌ ERROR: Expected version '$env:EXPECTED_VERSION' is not a valid semantic version."
7575
exit 1
7676
}
77-
77+
cargo generate-lockfile
7878
$pkgid = cargo pkgid --quiet
7979
if ($pkgid -match "#(.+)$") {
8080
$currentVersion = $matches[1]

0 commit comments

Comments
 (0)