mirror of
https://github.com/rtk-ai/rtk.git
synced 2026-09-19 07:33:17 +08:00
6303e9530a
- Cleaned all files for a more reusable cicd - Added pre-release on develop - Added jobs dependencies to gain time (avoid running all if mandatory fail) - Add CICD.md documentation
106 lines
3.4 KiB
YAML
106 lines
3.4 KiB
YAML
name: CD
|
|
|
|
on:
|
|
push:
|
|
branches: [develop, master]
|
|
|
|
concurrency:
|
|
group: cd-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
# ═══════════════════════════════════════════════
|
|
# DEVELOP PATH: Pre-release
|
|
# ═══════════════════════════════════════════════
|
|
|
|
pre-release:
|
|
if: github.ref == 'refs/heads/develop'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
tag: ${{ steps.tag.outputs.tag }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Compute pre-release tag
|
|
id: tag
|
|
run: |
|
|
VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2)
|
|
TAG="v${VERSION}-rc.${{ github.run_number }}"
|
|
|
|
# Safety: warn if this base version is already released
|
|
if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q .; then
|
|
echo "::warning::v${VERSION} already released. Consider bumping Cargo.toml on develop."
|
|
fi
|
|
|
|
# Safety: fail if this exact tag already exists
|
|
if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q .; then
|
|
echo "::error::Tag ${TAG} already exists"
|
|
exit 1
|
|
fi
|
|
|
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
|
echo "Pre-release tag: $TAG"
|
|
|
|
build-prerelease:
|
|
name: Build pre-release
|
|
needs: pre-release
|
|
if: needs.pre-release.outputs.tag != ''
|
|
uses: ./.github/workflows/release.yml
|
|
with:
|
|
tag: ${{ needs.pre-release.outputs.tag }}
|
|
prerelease: true
|
|
permissions:
|
|
contents: write
|
|
secrets: inherit
|
|
|
|
# ═══════════════════════════════════════════════
|
|
# MASTER PATH: Full release
|
|
# ═══════════════════════════════════════════════
|
|
|
|
release-please:
|
|
if: github.ref == 'refs/heads/master'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
release_created: ${{ steps.release.outputs.release_created }}
|
|
tag_name: ${{ steps.release.outputs.tag_name }}
|
|
steps:
|
|
- uses: googleapis/release-please-action@v4
|
|
id: release
|
|
with:
|
|
release-type: rust
|
|
package-name: rtk
|
|
|
|
build-release:
|
|
name: Build and upload release assets
|
|
needs: release-please
|
|
if: ${{ needs.release-please.outputs.release_created == 'true' }}
|
|
uses: ./.github/workflows/release.yml
|
|
with:
|
|
tag: ${{ needs.release-please.outputs.tag_name }}
|
|
permissions:
|
|
contents: write
|
|
secrets: inherit
|
|
|
|
update-latest-tag:
|
|
name: Update 'latest' tag
|
|
needs: [release-please, build-release]
|
|
if: ${{ needs.release-please.outputs.release_created == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Update latest tag
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git tag -fa latest -m "Latest stable release (${{ needs.release-please.outputs.tag_name }})"
|
|
git push origin latest --force
|