Skip to content

Commit

Permalink
ci: update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
halildurmus committed Nov 17, 2024
1 parent ed7ef0c commit 25eb3f4
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 104 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/health.yml

This file was deleted.

35 changes: 1 addition & 34 deletions .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,10 @@ on:
workflow_dispatch:

jobs:
check-version:
defaults:
run:
working-directory: packages/win32

runs-on: ubuntu-latest

outputs:
needs_release: ${{ steps.check_version.outputs.needs_release }}

steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4

- name: 🔍 Check if New Release is Needed
id: check_version
run: |
# Extract the version from the pubspec.yaml and trim any extra spaces
current_version=$(grep '^version:' pubspec.yaml | awk '{print $2}' | xargs)
# Output the current version
echo "Current Version: $current_version"
# Check if the current version has "-wip" suffix
if [[ "$current_version" == *"-wip" ]]; then
echo "A new release is needed based on version suffix."
echo "needs_release=true" >> $GITHUB_OUTPUT
else
echo "No new release is needed."
echo "needs_release=false" >> $GITHUB_OUTPUT
fi
prepare-release:
needs: check-version
if: needs.check-version.outputs.needs_release == 'true'
uses: halildurmus/workflows/.github/workflows/prepare_release.yml@main
with:
update_changelog_args: '--include-path "packages/win32/**/*" --repository "../../"'
working_directory: packages/win32
secrets:
token: ${{ secrets.PAT }}
44 changes: 6 additions & 38 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,13 @@ name: Publish

on:
push:
branches: [main]
paths:
- packages/win32/CHANGELOG.md
- packages/win32/pubspec.yaml
tags: ['v[0-9]+.[0-9]+.[0-9]+*']

jobs:
check-release:
runs-on: ubuntu-latest

outputs:
should_publish: ${{ steps.check_release.outputs.should_publish }}

steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4

- name: 🔍 Check if There is a Release Commit
id: check_release
run: |
# Get the latest commit message
latest_commit_msg=$(git log -1 --pretty=%B)
# Output the latest commit message
echo "Latest commit message: $latest_commit_msg"
# Check if the commit message matches the release pattern
if [[ "$latest_commit_msg" =~ ^chore\(release\):\ v.* ]]; then
echo "Release commit found."
echo "should_publish=true" >> $GITHUB_OUTPUT
else
echo "No release commit found."
echo "should_publish=false" >> $GITHUB_OUTPUT
fi
publish:
needs: check-release
if: needs.check-release.outputs.should_publish == 'true'
uses: halildurmus/workflows/.github/workflows/dart_pub_publish.yml@main
name: Publish to pub.dev
permissions:
id-token: write
uses: dart-lang/setup-dart/.github/workflows/publish.yml@main
with:
working_directory: packages/win32
secrets:
token: ${{ secrets.PAT }}
working-directory: packages/win32
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
push:
branches: [main]
paths:
- packages/win32/CHANGELOG.md
- packages/win32/pubspec.yaml
workflow_dispatch:

jobs:
check-release:
if: ${{ github.event_name != 'workflow_dispatch' }}

runs-on: ubuntu-latest

outputs:
should_publish: ${{ steps.check_release.outputs.should_publish }}

steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4

- name: 🔍 Check if There is a Release Commit
id: check_release
run: |
latest_commit_msg=$(git log -1 --pretty=format:%s)
echo "📜 Latest commit: $latest_commit_msg"
if [[ "$latest_commit_msg" =~ ^chore\(release\):\ v.* ]]; then
echo "🎉 Release commit detected. Proceeding with the publish step."
echo "should_publish=true" >> $GITHUB_OUTPUT
else
echo "❌ No release commit detected. Skipping the publish step."
echo "should_publish=false" >> $GITHUB_OUTPUT
fi
release:
needs: [check-release]
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-release.outputs.should_publish == 'true' }}
uses: halildurmus/workflows/.github/workflows/dart_release.yml@main
with:
working_directory: packages/win32
secrets:
token: ${{ secrets.PAT }}
28 changes: 16 additions & 12 deletions packages/win32/PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ Go to the [GitHub Actions] tab and trigger the [Prepare Release] workflow.

This workflow will:

- 🔄 **Remove** the `-wip` suffix from the version number in the `pubspec.yaml`
file _(e.g., `6.1.0-wip` ➡️ `6.1.0`)_
- 📝 **Update** the `CHANGELOG.md` file:
- Replace `## unreleased` with the new version number and today’s date
_(e.g., `## unreleased` ➡️ `## [6.1.0] - 2025-06-15`)_
- 🔼 **Bump** the `version` in the `pubspec.yaml` file based on commit messages
_(e.g., `6.0.0` ➡️ `6.1.0`)_.
- 📝 **Update** the `CHANGELOG.md` file with the latest changes.

After making these changes, the workflow will create a pull request (PR)
_(e.g., **`chore(release): v6.1.0`**)_.
Expand All @@ -22,16 +20,22 @@ _(e.g., **`chore(release): v6.1.0`**)_.
Open the PR created by the workflow, review the changes, and **merge it** into
the main branch.

## 3️⃣ Automatic Publishing
## 3️⃣ Automatic Release and Publishing

Once the PR is merged:
After merging the PR, the following workflows will automatically be triggered:

- The [Publish] workflow will be triggered automatically.
- This workflow will:
- 📦 **Create** a new release on GitHub with a corresponding Git tag.
- 🚀 **Publish** the new package version to [pub.dev].
### 📦 **Release** Workflow

- The [Release] workflow workflow will **create** a new release on GitHub with
the corresponding Git tag.

### 🚀 **Publish** Workflow

- After the Git tag is created, the [Publish] workflow will be triggered to
**publish** the new package version to [pub.dev].

[GitHub Actions]: https://github.com/halildurmus/win32/actions
[Prepare Release]: https://github.com/halildurmus/win32/blob/main/.github/workflows/prepare_release.yml
[Publish]: https://github.com/halildurmus/win32/blob/main/.github/workflows/publish.yml
[pub.dev]: https://pub.dev
[Publish]: https://github.com/halildurmus/win32/blob/main/.github/workflows/publish.yml
[Release]: https://github.com/halildurmus/win32/blob/main/.github/workflows/release.yml
2 changes: 0 additions & 2 deletions website/docs/guides-concepts/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ The following hooks run automatically with Lefthook:
- `format`: Formats code according to Dart guidelines.
- `test_generator`: Runs tests for `package:generator` to ensure stability.
- `test_win32`: Runs tests for `package:win32` to ensure stability.
- `bump_version`: Increments the version number based on commit messages.
- `update_changelog`: Generates a changelog based on commit messages.

- **Commit-msg Hook**:
- `check_commit`: Ensures the commit message follows [Conventional Commits].
Expand Down

0 comments on commit 25eb3f4

Please sign in to comment.