migrate update manifest job to publish workflow

This commit is contained in:
Harivansh Rathi 2026-03-26 09:11:13 -04:00
parent deaffff45a
commit 47047e9064
2 changed files with 43 additions and 86 deletions

View file

@ -52,32 +52,13 @@ jobs:
echo "rust=${{ steps.filter.outputs.rust }}" >> "$GITHUB_OUTPUT"
fi
- name: Calculate next version
- name: Read current version
id: version
if: github.event_name != 'pull_request' && steps.check.outputs.rust == 'true'
run: |
BASE=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE"
LATEST=$(git tag -l "v${MAJOR}.${MINOR}.*" | sort -V | tail -1)
if [ -z "$LATEST" ]; then
NEW="$BASE"
else
LATEST_VER="${LATEST#v}"
IFS='.' read -r _ _ LATEST_PATCH <<< "$LATEST_VER"
NEW_PATCH=$((LATEST_PATCH + 1))
NEW="${MAJOR}.${MINOR}.${NEW_PATCH}"
fi
# Ensure the computed version does not already have a tag
while git rev-parse "v${NEW}" >/dev/null 2>&1; do
IFS='.' read -r MAJOR MINOR PATCH <<< "$NEW"
NEW="${MAJOR}.${MINOR}.$((PATCH + 1))"
done
echo "version=${NEW}" >> "$GITHUB_OUTPUT"
echo "tag=v${NEW}" >> "$GITHUB_OUTPUT"
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
validate:
name: Validate
@ -167,57 +148,13 @@ jobs:
- name: Distribution validation
run: make dist-validate
update-manifests:
name: Update Manifests
needs: [changes, validate, integration, distribution]
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Update version in Cargo.toml
run: |
CURRENT=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
NEW="${{ needs.changes.outputs.version }}"
if [ "$CURRENT" != "$NEW" ]; then
sed -i "0,/^version = \"${CURRENT}\"/s//version = \"${NEW}\"/" Cargo.toml
node -e 'const fs=require("node:fs"); const path="npm/deskctl/package.json"; const pkg=JSON.parse(fs.readFileSync(path,"utf8")); pkg.version=process.argv[1]; fs.writeFileSync(path, JSON.stringify(pkg, null, 2)+"\n");' "$NEW"
cargo generate-lockfile
fi
- name: Commit, tag, and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if ! git diff --quiet; then
git add Cargo.toml Cargo.lock npm/deskctl/package.json
git commit -m "release: ${{ needs.changes.outputs.tag }} [skip ci]"
fi
if ! git rev-parse "${{ needs.changes.outputs.tag }}" >/dev/null 2>&1; then
git tag "${{ needs.changes.outputs.tag }}"
fi
git push origin main --tags
build:
name: Build Release Asset
needs: [changes, update-manifests]
needs: [changes, validate, integration, distribution]
if: github.event_name != 'pull_request' && needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.changes.outputs.tag }}
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
@ -242,7 +179,7 @@ jobs:
release:
name: Release
needs: [changes, build, update-manifests]
needs: [changes, build]
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps: