ci: Updated the release flow to also update the Cargo.toml version automatically

This commit is contained in:
2025-08-29 13:45:14 -06:00
parent 049a0c5d49
commit 80bc6793c7
2 changed files with 58 additions and 4 deletions
+1
View File
@@ -1,3 +1,4 @@
--artifact-server-path=./.act/artifacts --artifact-server-path=./.act/artifacts
--cache-server-path=./.act/cache --cache-server-path=./.act/cache
--container-options --privileged
--env ACT=true --env ACT=true
+57 -4
View File
@@ -87,11 +87,44 @@ jobs:
echo "prev_version=$PREV_TAG" >> $GITHUB_ENV echo "prev_version=$PREV_TAG" >> $GITHUB_ENV
- name: Bump Cargo.toml version - name: Bump Cargo.toml version
shell: bash
working-directory: ${{ github.workspace }}
env:
VERSION: ${{ env.version }}
run: | run: |
sed -E -i '/^name = "managarr"$/ { n; s|^version = "[^"]*"|version = "'"${{ env.version }}"'"| }' Cargo.toml set -euo pipefail
cargo update : "${VERSION:?env.version is empty}"
git add Cargo.toml Cargo.lock
git commit -m "chore: Bump the version in Cargo.toml" # Ignore Act's local artifact dir noise
echo artifacts/ >> .git/info/exclude || true
# Edit the version line right after name="managarr"
sed -E -i '
/^[[:space:]]*name[[:space:]]*=[[:space:]]*"managarr"[[:space:]]*$/ {
n
s|^[[:space:]]*version[[:space:]]*=[[:space:]]*"[^"]*"|version = "'"$VERSION"'"|
}
' Cargo.toml
cargo update || true
# Git config that helps in containers (Act)
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Debug: show what changed
git status --porcelain
git diff --name-only -- Cargo.toml Cargo.lock || true
# Only commit if one of these files actually changed
if ! git diff --quiet -- Cargo.toml Cargo.lock; then
# Stage only modifications of already tracked files (won't pick up artifacts/)
git add -u -- Cargo.toml Cargo.lock
git commit -m "chore: bump Cargo.toml to $VERSION"
else
echo "No changes to commit (already at $VERSION)"
fi
- name: Generate changelog for the version bump - name: Generate changelog for the version bump
id: changelog id: changelog
@@ -112,6 +145,15 @@ jobs:
with: with:
path: artifacts path: artifacts
- name: Upload the changed Cargo files (Act)
if: env.ACT == 'true'
uses: actions/upload-artifact@v4
with:
name: bumped-cargo-files
path: |
Cargo.toml
Cargo.lock
build-release-artifacts: build-release-artifacts:
name: build-release name: build-release
needs: [bump-version] needs: [bump-version]
@@ -150,10 +192,18 @@ jobs:
fetch-depth: 1 fetch-depth: 1
- name: Ensure repository is up-to-date - name: Ensure repository is up-to-date
if: env.ACT != 'true'
run: | run: |
git fetch --all git fetch --all
git pull git pull
- name: Get bumped Cargo files (Act)
if: env.ACT == 'true'
uses: actions/download-artifact@v4
with:
name: bumped-cargo-files
path: ${{ github.workspace }}
- uses: actions/cache@v3 - uses: actions/cache@v3
name: Cache Cargo registry name: Cache Cargo registry
with: with:
@@ -268,6 +318,7 @@ jobs:
merge-multiple: true merge-multiple: true
- name: Ensure repository is up-to-date - name: Ensure repository is up-to-date
if: env.ACT != 'true'
run: | run: |
git fetch --all git fetch --all
git pull git pull
@@ -450,6 +501,7 @@ jobs:
merge-multiple: true merge-multiple: true
- name: Ensure repository is up-to-date - name: Ensure repository is up-to-date
if: env.ACT != 'true'
run: | run: |
git fetch --all git fetch --all
git pull git pull
@@ -502,6 +554,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Ensure repository is up-to-date - name: Ensure repository is up-to-date
if: env.ACT != 'true'
run: | run: |
git fetch --all git fetch --all
git pull git pull