Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ on:
- major

permissions:
actions: write
contents: write
pull-requests: write

jobs:
bump:
name: Bump & Tag
name: Bump & Open PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -52,11 +54,22 @@ jobs:
sed -i 's/^version:.*/version: ${{ steps.version.outputs.new }}/' charts/flywheel/Chart.yaml
sed -i 's/^appVersion:.*/appVersion: "${{ steps.version.outputs.new }}"/' charts/flywheel/Chart.yaml

- name: Commit and tag
- name: Commit and open pull request
env:
GH_TOKEN: ${{ github.token }}
run: |
branch="release/v${{ steps.version.outputs.new }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git switch --create "$branch"
git add Cargo.toml Cargo.lock charts/flywheel/Chart.yaml
git commit -m "release: v${{ steps.version.outputs.new }}"
git tag "v${{ steps.version.outputs.new }}"
git push origin main --tags
git commit -m "chore(release): bump to v${{ steps.version.outputs.new }}"
git push --set-upstream origin "$branch"

pr_url=$(gh pr create \
--base main \
--head "$branch" \
--title "chore(release): bump to v${{ steps.version.outputs.new }}" \
--body "Prepare the v${{ steps.version.outputs.new }} release. CI was dispatched explicitly because pull requests created with GITHUB_TOKEN do not emit another workflow event.")
gh workflow run ci.yaml --ref "$branch"
echo "Created $pr_url" >> "$GITHUB_STEP_SUMMARY"
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: CI
on:
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
Expand Down
39 changes: 29 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ name: Release

on:
workflow_dispatch:
workflow_run:
workflows: ["Bump Version"]
types:
- completed
push:
branches: [main]

permissions:
contents: write
Expand All @@ -14,32 +12,50 @@ permissions:
env:
CARGO_TERM_COLOR: always

concurrency:
group: release
cancel-in-progress: false

jobs:
resolve-tag:
name: Resolve Tag
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
release: ${{ steps.tag.outputs.release }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get latest tag
- name: Resolve release tag
id: tag
run: |
tag=$(git tag --sort=-v:refname | grep '^v' | head -1)
if [ -z "$tag" ]; then
echo "::error::No version tag found"
exit 1
version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
tag="v${version}"

if git rev-parse --verify --quiet "refs/tags/$tag" >/dev/null; then
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "Tag $tag already exists; there is nothing to release."
echo "release=false" >> "$GITHUB_OUTPUT"
else
echo "release=true" >> "$GITHUB_OUTPUT"
fi
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "$tag"
git push origin "$tag"
echo "release=true" >> "$GITHUB_OUTPUT"
fi

echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "Resolved tag: $tag"

ci:
name: CI
needs: [resolve-tag]
if: needs.resolve-tag.outputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -58,6 +74,7 @@ jobs:
docker:
name: Docker
needs: [resolve-tag, ci]
if: needs.resolve-tag.outputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -86,6 +103,7 @@ jobs:
helm:
name: Helm Chart
needs: [resolve-tag, docker]
if: needs.resolve-tag.outputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -131,6 +149,7 @@ jobs:
release:
name: GitHub Release
needs: [resolve-tag, docker, helm]
if: needs.resolve-tag.outputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
Loading