Skip to content

Commit 023ef26

Browse files
committed
separate build and release worlflows
1 parent 7c305c1 commit 023ef26

File tree

2 files changed

+99
-65
lines changed

2 files changed

+99
-65
lines changed

.github/workflows/build.yaml

Lines changed: 44 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
name: Build and Release
1+
name: Build
22

33
on:
4-
workflow_dispatch:
54
push:
6-
branches: [ main ]
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
78

89
env:
910
CARGO_TERM_COLOR: always
@@ -17,67 +18,45 @@ jobs:
1718
strategy:
1819
matrix:
1920
target: [i686-pc-windows-msvc, x86_64-pc-windows-msvc]
20-
steps:
21-
- uses: actions/checkout@v4
22-
23-
- name: Install Rust
24-
uses: actions-rs/toolchain@v1
25-
with:
26-
profile: minimal
27-
toolchain: stable
28-
target: ${{ matrix.target }}
29-
override: true
30-
31-
- name: Build for target
32-
run: cargo build --release --target=${{ matrix.target }}
33-
34-
- name: Rename DLLs
35-
run: |
36-
$target = "${{ matrix.target }}"
37-
$originalPath = "target\$target\release\$env:PROJECT_NAME.dll"
3821

39-
if ($target -eq "i686-pc-windows-msvc") {
40-
$newPath = "target\$target\release\$env:NAME_WIN32"
41-
} else {
42-
$newPath = "target\$target\release\$env:NAME_WIN64"
43-
}
44-
45-
if (Test-Path $originalPath) {
46-
Move-Item -Path $originalPath -Destination $newPath -Force
47-
Write-Host "Renamed $originalPath to $newPath"
48-
} else {
49-
Write-Host "File not found: $originalPath"
50-
exit 1
51-
}
52-
shell: pwsh
53-
54-
- name: Upload artifacts
55-
uses: actions/[email protected]
56-
with:
57-
name: ${{ matrix.target }}-dll
58-
path: target/${{ matrix.target }}/release/${{ matrix.target == 'i686-pc-windows-msvc' && env.NAME_WIN32 || env.NAME_WIN64 }}
59-
60-
release:
61-
needs: build
62-
runs-on: ubuntu-latest
6322
steps:
64-
- name: Download artifacts
65-
uses: actions/[email protected]
66-
with:
67-
path: artifacts
68-
69-
- name: Get current date for CalVer
70-
id: date
71-
run: echo "version=$(date +'%Y.%-m.%-d')" >> $GITHUB_OUTPUT
72-
73-
- name: Create tag and release
74-
uses: softprops/action-gh-release@v1
75-
with:
76-
tag_name: v${{ steps.date.outputs.version }}
77-
name: Release v${{ steps.date.outputs.version }}
78-
body: "Automated release with 32-bit and 64-bit DLLs"
79-
files: |
80-
artifacts/i686-pc-windows-msvc-dll/${{ env.NAME_WIN32 }}
81-
artifacts/x86_64-pc-windows-msvc-dll/${{ env.NAME_WIN64 }}
82-
env:
83-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
- name: Checkout source
24+
uses: actions/checkout@v4
25+
26+
- name: Install Rust toolchain
27+
uses: actions-rs/toolchain@v1
28+
with:
29+
profile: minimal
30+
toolchain: stable
31+
target: ${{ matrix.target }}
32+
override: true
33+
34+
- name: Build for ${{ matrix.target }}
35+
run: cargo build --release --target=${{ matrix.target }}
36+
37+
- name: Rename output DLL
38+
run: |
39+
$target = "${{ matrix.target }}"
40+
$original = "target\$target\release\$env:PROJECT_NAME.dll"
41+
42+
if ($target -eq "i686-pc-windows-msvc") {
43+
$renamed = "target\$target\release\$env:NAME_WIN32"
44+
} else {
45+
$renamed = "target\$target\release\$env:NAME_WIN64"
46+
}
47+
48+
if (Test-Path $original) {
49+
Move-Item $original $renamed -Force
50+
Write-Host "Renamed $original to $renamed"
51+
} else {
52+
Write-Host "DLL not found: $original"
53+
exit 1
54+
}
55+
shell: pwsh
56+
57+
- name: Upload artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: ${{ matrix.target }}-dll
61+
path: |
62+
target/${{ matrix.target }}/release/${{ matrix.target == 'i686-pc-windows-msvc' && env.NAME_WIN32 || env.NAME_WIN64 }}

.github/workflows/version.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version:
2+
needs: build
3+
if: github.ref == 'refs/heads/main'
4+
runs-on: ubuntu-latest
5+
6+
steps:
7+
- name: Checkout repository
8+
uses: actions/checkout@v4
9+
10+
- name: Set up Git
11+
run: |
12+
git config --global user.name "Wasp Bot"
13+
git config --global user.email "[email protected]"
14+
15+
- name: Get current date and commit hash
16+
run: |
17+
echo "CURRENT_YEAR=$(date +'%Y')" >> $GITHUB_ENV
18+
echo "CURRENT_MONTH=$(date +'%m')" >> $GITHUB_ENV
19+
echo "CURRENT_DAY=$(date +'%d')" >> $GITHUB_ENV
20+
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
21+
22+
- name: Update version.simba
23+
run: |
24+
sed -i "s/WL_VERSION_YEAR: Integer = .*/WL_VERSION_YEAR: Integer = $CURRENT_YEAR;/" version.simba
25+
sed -i "s/WL_VERSION_MONTH: Integer = .*/WL_VERSION_MONTH: Integer = $CURRENT_MONTH;/" version.simba
26+
sed -i "s/WL_VERSION_DAY: Integer = .*/WL_VERSION_DAY: Integer = $CURRENT_DAY;/" version.simba
27+
sed -i "s/WL_VERSION_COMMIT_HASH: String = .*/WL_VERSION_COMMIT_HASH: String = '$COMMIT_HASH';/" version.simba
28+
29+
- name: Commit version bump
30+
run: |
31+
git add version.simba
32+
git commit -m "Automatic version bump to $CURRENT_YEAR.$CURRENT_MONTH.$CURRENT_DAY-$COMMIT_HASH"
33+
git push
34+
35+
- name: Create and push tag
36+
run: |
37+
TAG_NAME="$CURRENT_YEAR.$CURRENT_MONTH.$CURRENT_DAY-$COMMIT_HASH"
38+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
39+
git tag $TAG_NAME
40+
git push origin $TAG_NAME
41+
42+
- name: Download build artifacts
43+
uses: actions/download-artifact@v4
44+
with:
45+
path: artifacts
46+
47+
- name: Create GitHub release
48+
run: |
49+
gh release create $TAG_NAME \
50+
artifacts/i686-pc-windows-msvc-dll/${{ env.NAME_WIN32 }} \
51+
artifacts/x86_64-pc-windows-msvc-dll/${{ env.NAME_WIN64 }} \
52+
--title "Release v$TAG_NAME" \
53+
--notes "Automated release with 32-bit and 64-bit DLLs"
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)