Skip to content

Commit 856861a

Browse files
authored
code hygene and workflow release changes (#16)
Signed-off-by: Daniel Guns <danbguns@gmail.com>
1 parent 335eb83 commit 856861a

19 files changed

Lines changed: 501 additions & 665 deletions
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Auto Tag Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
jobs:
9+
auto-tag:
10+
# Only run on merged PRs with 'release' label
11+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: main
19+
fetch-depth: 0
20+
21+
- name: Get version from Cargo.toml
22+
id: version
23+
run: |
24+
VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2)
25+
echo "version=$VERSION" >> $GITHUB_OUTPUT
26+
echo "Found version: $VERSION"
27+
28+
- name: Check if tag already exists
29+
id: check_tag
30+
run: |
31+
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
32+
echo "exists=true" >> $GITHUB_OUTPUT
33+
echo "Tag v${{ steps.version.outputs.version }} already exists"
34+
else
35+
echo "exists=false" >> $GITHUB_OUTPUT
36+
echo "Tag v${{ steps.version.outputs.version }} does not exist"
37+
fi
38+
39+
- name: Create and push tag
40+
if: steps.check_tag.outputs.exists == 'false'
41+
run: |
42+
git config user.name "github-actions[bot]"
43+
git config user.email "github-actions[bot]@users.noreply.github.com"
44+
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
45+
git push origin "v${{ steps.version.outputs.version }}"
46+
echo "✅ Created and pushed tag v${{ steps.version.outputs.version }}"
47+
48+
- name: Tag already exists
49+
if: steps.check_tag.outputs.exists == 'true'
50+
run: |
51+
echo "⚠️ Tag v${{ steps.version.outputs.version }} already exists, skipping tag creation"

.github/workflows/bump-version.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# .github/workflows/prepare-release.yml
2+
name: Prepare Release
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
bump:
8+
description: "Version bump type"
9+
required: true
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
jobs:
17+
prepare-release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Install Rust
25+
uses: dtolnay/rust-toolchain@stable
26+
27+
- name: Calculate new version
28+
id: version
29+
run: |
30+
# Get current version from Cargo.toml
31+
CURRENT=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2)
32+
33+
# Calculate new version based on bump type
34+
IFS='.' read -r major minor patch <<< "$CURRENT"
35+
36+
case "${{ inputs.bump }}" in
37+
major)
38+
major=$((major + 1))
39+
minor=0
40+
patch=0
41+
;;
42+
minor)
43+
minor=$((minor + 1))
44+
patch=0
45+
;;
46+
patch)
47+
patch=$((patch + 1))
48+
;;
49+
esac
50+
51+
NEW_VERSION="$major.$minor.$patch"
52+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
53+
echo "current_version=$CURRENT" >> $GITHUB_OUTPUT
54+
echo "Bumping from $CURRENT to $NEW_VERSION"
55+
56+
- name: Update Cargo.toml
57+
run: |
58+
sed -i 's/^version = ".*"/version = "${{ steps.version.outputs.new_version }}"/' Cargo.toml
59+
60+
- name: Update Cargo.lock
61+
run: |
62+
cargo update -p flux9s --precise ${{ steps.version.outputs.new_version }}
63+
64+
- name: Update CHANGELOG.md
65+
run: |
66+
VERSION="${{ steps.version.outputs.new_version }}"
67+
DATE=$(date +%Y-%m-%d)
68+
69+
# Create the new changelog entry
70+
cat > /tmp/changelog_entry.txt << EOF
71+
72+
## [$VERSION] - $DATE
73+
74+
### Added
75+
-
76+
77+
### Changed
78+
-
79+
80+
### Fixed
81+
-
82+
EOF
83+
84+
# Insert after the [Unreleased] line
85+
sed -i "/^## \[Unreleased\]/r /tmp/changelog_entry.txt" CHANGELOG.md
86+
87+
- name: Create Pull Request
88+
uses: peter-evans/create-pull-request@v5
89+
with:
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
commit-message: "chore: bump version to ${{ steps.version.outputs.new_version }}"
92+
title: "Release v${{ steps.version.outputs.new_version }}"
93+
body: |
94+
## Release v${{ steps.version.outputs.new_version }}
95+
96+
This PR prepares the release for v${{ steps.version.outputs.new_version }}.
97+
98+
**Version bump:** ${{ steps.version.outputs.current_version }} → ${{ steps.version.outputs.new_version }} (${{ inputs.bump }})
99+
100+
**Changes in this PR:**
101+
- ✅ Updated version in Cargo.toml
102+
- ✅ Updated Cargo.lock
103+
- ✅ Updated CHANGELOG.md with new version entry
104+
105+
**What happens after merge:**
106+
1. ✅ PR gets merged to main
107+
2. ✅ Tag `v${{ steps.version.outputs.new_version }}` is automatically created
108+
3. ✅ Release workflow builds binaries for all platforms
109+
4. ✅ Publishes to crates.io
110+
5. ✅ Creates GitHub release with artifacts
111+
6. ✅ Updates Homebrew formula
112+
113+
**Please update the CHANGELOG.md** with actual changes before merging!
114+
branch: release-v${{ steps.version.outputs.new_version }}
115+
delete-branch: true
116+
labels: release

.github/workflows/release.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,6 @@ jobs:
3131
- name: Run tests
3232
run: cargo test --lib --tests --test crd_compatibility --test resource_registry --test model_compatibility --test field_extraction
3333

34-
- name: Extract version from tag
35-
id: get_version
36-
run: |
37-
VERSION=${GITHUB_REF#refs/tags/v}
38-
echo "version=$VERSION" >> $GITHUB_OUTPUT
39-
echo "Extracted version: $VERSION"
40-
41-
- name: Verify version matches Cargo.toml
42-
run: |
43-
CARGO_VERSION=$(grep '^version = ' Cargo.toml | cut -d'"' -f2)
44-
TAG_VERSION=${{ steps.get_version.outputs.version }}
45-
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
46-
echo "Error: Version mismatch!"
47-
echo "Cargo.toml version: $CARGO_VERSION"
48-
echo "Tag version: $TAG_VERSION"
49-
exit 1
50-
fi
51-
echo "Version match confirmed: $CARGO_VERSION"
52-
5334
build:
5435
name: Build ${{ matrix.target }}
5536
needs: test
@@ -62,14 +43,11 @@ jobs:
6243
artifact_name: flux9s
6344
asset_name: flux9s-linux-x86_64.tar.gz
6445

65-
# macOS ARM (M1/M2/M3) - build on native runner
6646
- os: macos-latest
6747
target: aarch64-apple-darwin
6848
artifact_name: flux9s
6949
asset_name: flux9s-macos-aarch64.tar.gz
7050

71-
# macOS Intel - build on native runner
72-
# Note: GitHub Actions macos-latest is now ARM, so we use macos-13 for Intel
7351
- os: macos-13
7452
target: x86_64-apple-darwin
7553
artifact_name: flux9s

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)