Skip to content

Commit

Permalink
chore(ribir): 🤖 GitHub actions for development cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Adoo committed Jan 17, 2024
1 parent fe5ac5d commit 2b94338
Show file tree
Hide file tree
Showing 14 changed files with 240 additions and 94 deletions.
6 changes: 0 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "npm"
# Look for `package.json` and `lock` files in the `root` directory
directory: "/"
# Check the npm registry for updates every day (weekdays)
schedule:
interval: "weekly"
10 changes: 0 additions & 10 deletions .github/pull_request.md

This file was deleted.

16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Purpose of this Pull Request

*Please briefly describe what this Pull Request is aiming to achieve.*

## Checklist Before Merging

Please ensure the following are completed before merging:
- [ ] If this is linked to an issue, include the link in your description.
- [ ] If you've made changes to the code or documentation, make sure these are updated in the `CHANGELOG.md` file.
- [ ] If you've introduced any break changes, briefly describe them in the `Breaking` section of the `CHANGELOG.md` file.

## Additional Information

If you're unsure about which branch to submit your Pull Request to, or when it will be released after being merged, please refer to our [Release Guide](./RELEASE.md).

If you're working on a widget and need help writing test cases, we have some macros that can assist you. Please refer to the [Ribir Dev Helper](https://docs.rs/ribir_dev_helper) documentation.
76 changes: 0 additions & 76 deletions .github/workflows/alpha-release.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/alpha-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: "0 22 * * 2" # runs every tuesday at 22:00 UTC+0
permissions:
contents: write
name: "Alpha Version"
jobs:
master_check:
runs-on: ubuntu-latest
steps:
- name: Master check
if: github.ref != 'refs/heads/master'
run: |
echo "Alpha version can be released only from master branch"
exit 1
call-workflow-passing-data:
needs: master_check
uses: RibirX/rclog/.github/workflows/release-version.yml@main
with:
level: 'alpha'
ref: ${{ github.ref }}
merge_changelog: false
secrets:
CRATE_RELEASE_TOKEN: ${{ secrets.CRATE_RELEASE_TOKEN }}
GITHUB_RELEASE_TOKEN: ${{ secrets.RIBIR_RELEASE }}
31 changes: 31 additions & 0 deletions .github/workflows/dispatch-other-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Dispatch other repo"

on:
workflow_dispatch:
push:
branches:
- main
- release-*
jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.RIBIR_RELEASE }}
script: |-
await github.rest.actions.createWorkflowDispatch({
owner: 'RibirX',
repo: 'ribir-website',
workflow_id: 'sync-docs.yml',
ref: 'main',
inputs: {
branch_ref: "${{ github.ref }}"
},
}).catch(error => error).then(response => {
core.debug(response);
if (response.status !== 204) {
core.setFailed(`create workflow_dispatch received status code ${response.status}`);
}
});
63 changes: 63 additions & 0 deletions .github/workflows/new-dev-cycle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "New Development Cycle"
on:
workflow_dispatch: # allows manual triggering
permissions:
contents: write

jobs:
master_check:
runs-on: ubuntu-latest
steps:
- name: master branch check
if: github.ref != 'refs/heads/master'
run: |
echo "You should only start a new cycle of development from the master branch."
exit 1
release_beta:
needs: master_check
uses: RibirX/rclog/.github/workflows/release-version.yml@main
with:
level: 'beta'
ref: ${{ github.ref }}
merge_changelog: true
secrets:
CRATE_RELEASE_TOKEN: ${{ secrets.CRATE_RELEASE_TOKEN }}
GITHUB_RELEASE_TOKEN: ${{ secrets.RIBIR_RELEASE }}
checkout_relase_branch:
needs: release_beta
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
token: ${{ secrets.RIBIR_RELEASE }}
- name: Install cargo-release
uses: taiki-e/install-action@v2
with:
tool: cargo-release
- name: Intasll semver tool
run: npm install -g semver
- name: new release branch & alpha version
run: |
git config --global user.name "RChangelog[bot]"
git config --global user.email 155627257+RChangelog[bot]@users.noreply.github.com
# need a pull, release a beta version before
git pull --rebase
version=$(git describe --tags --abbrev=0 | grep -oP '(?<=v)\S*')
version=$(semver $version -c)
branch_name=release-$(echo $version | grep -oP '[0-9]+.[0-9]+').x
git checkout -b $branch_name
git push --set-upstream origin $branch_name
# relase a empty new alpha version without tag and publish or any changelog update
git checkout master
cargo login ${{secrets.CRATE_RELEASE_TOKEN}}
new_alpha_version=$(semver $version -i minor)-alpha.0
echo "publish = false" >> /tmp/$new_alpha_version.toml
echo "tag = false" >> /tmp/$new_alpha_version.toml
echo "pre-release-replacements = []" >> /tmp/$new_alpha_version.toml
echo 'pre-release-hook = ["echo", "no replace in alpha.0"]' >> /tmp/$new_alpha_version.toml
cargo release $new_alpha_version -x --no-confirm -c /tmp/$new_alpha_version.toml
49 changes: 49 additions & 0 deletions .github/workflows/patch-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
workflow_dispatch: # allows manual triggering
inputs:
level:
description: 'Release a patch version on the release branch, `auto` follow the last version level.'
required: true
default: 'auto'
type: choice
options:
- 'auto'
- 'beta'
- 'rc'
- 'patch'
permissions:
contents: write
name: "Patch Version"
jobs:
release_level:
runs-on: ubuntu-latest
outputs:
level: ${{ steps.concrete_level.outputs.level }}
steps:
- name: Release branch check
if: startsWith(github.ref, 'refs/heads/release-') != true
run: |
echo "You should only run this workflow on the release branch."
exit 1
- uses: actions/checkout@v3
if: ${{ github.event.inputs.level == 'auto' }}
with:
fetch-depth: 0
fetch-tags: true
- id: auto_detect
if: ${{ github.event.inputs.level == 'auto' }}
run: echo "level=$(git describe --tags --abbrev=0 | grep -o "rc\|beta")" >> $GITHUB_OUTPUT
- id: concrete_level
run: |
level=${{ steps.auto_detect.outputs.level }}
echo "level=${level:=${{inputs.level}}}" >> $GITHUB_OUTPUT
call-workflow-passing-data:
needs: release_level
uses: RibirX/rclog/.github/workflows/release-version.yml@main
with:
level: ${{ needs.release_level.outputs.level }}
ref: ${{ github.ref }}
merge_changelog: ${{ needs.release_level.outputs.level == 'patch' }}
secrets:
CRATE_RELEASE_TOKEN: ${{ secrets.CRATE_RELEASE_TOKEN }}
GITHUB_RELEASE_TOKEN: ${{ secrets.RIBIR_RELEASE }}
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ tokio-stream = { version = "0.1" }
[workspace.metadata.release]
shared-version = true
tag = false
pre-release-hook = ["./rclog_hook.sh"]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Use Rust to build multi-platform applications from a single codebase.
[![Crates.io](https://img.shields.io/crates/v/ribir)](https://crates.io/crates/ribir)
[![Crates.io](https://img.shields.io/crates/d/ribir)](https://crates.io/crates/ribir)

[Website] | [Documents] | [Examples] | [Changelog]

[Website] | [Documents] | [中文文档] | [Examples] | [Changelog] | [Releases]
</div>

![](/static/img/hero-banner.png)
Expand Down Expand Up @@ -159,8 +158,10 @@ Ribir is [MIT-licensed](./LICENSE)

[Website]: https://ribir.org
[Changelog]: ./CHANGELOG.md
[Releases]: ./RELEASE.md
[Flutter]: https://flutter.dev/
[QML]: https://doc.qt.io/qt-6/qtqml-index.html
[Examples]: ./examples/
[Documents]: https://ribir.org/docs/introduction
[中文文档]: https://ribir.org/zh/docs/introduction
[wgpu]: https://github.com/gfx-rs/wgpu
44 changes: 44 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# RELEASES

This document outlines the release process and branch management for the Ribir project. Prior to version 1.0, we don't strictly adhere to [Semantic Versioning](https://semver.org/). Each minor version is treated as a major version and may contain breaking changes.

## Release Schedule

Until Ribir reaches a more stable version, releases are driven by development progress rather than a fixed schedule. However, our goal is to establish a monthly release cycle for minor versions, starting from the `0.3.0` version.

### Branch Management

Our goal is to keep the `master` branch in a working state at all times, ready for an alpha release whenever necessary. The `master` branch is used for active development and preparation for the next release. An alpha version is automatically released every week, allowing us to use the upcoming version during its development cycle.

Each minor release has its own distinct branch, named `release-<major>.<minor>.x`, such as `release-0.1.x`, `release-0.2.x`. Please avoid using names that start with `release-` for your development branches. To keep things manageable, we only maintain the most recent release branch.

If you wish to contribute to the current release, please submit a pull request to merge it into the `release-<major>.<minor>.x` branch. If you wish to contribute to the next release, please submit a pull request to merge it into the `master` branch.

Once the development of the next release is complete, we will release the `beta` version and create a new `release-<major>.<minor>.x` branch from the `master` branch. The `master` branch will then be used for the next release and will transition to the `<major>.<minor+1>.1-alpha-0` version.

In the release branch, we only accept bug fixes and documentation changes. All other changes should be merged into the `master` branch and will be included in the next release.

The diagram below provides a clear and simple overview of our branch management and version release process:

![Branch Management](./static/img/release-and-branch.svg)

### Tools

All version releases and branch management are handled by GitHub Actions. Administrators should not manually perform these tasks through the command line.

Here are the GitHub Actions you should be aware of:

- **Alpha release**: Every week, an alpha version is automatically released in the `master` branch. Manual triggering is also supported if needed.
- **New Development Cycle**: Starts a new development cycle when the next release is ready. Only supports manual triggering. This action will:
1. Release a beta version
2. Create a new release branch from the `master` branch
3. Update the version in the `master` branch to the next minor alpha version
- **Patch version**: Releases a beta, rc, or patch version in the release branch. Only supports manual triggering.

### Changelog Management

We use [keep a changelog](https://keepachangelog.com/en/1.0.0/) to manage the changelog. The changelog should be updated in every pull request and kept human-readable.

When a version is released, certain replacements will occur in the changelog, such as replacing `@Unreleased` with the version number. The changelog of the release version will be extracted to create a GitHub release note.

When a version transitions from alpha to beta, all alpha versions' changelogs will be merged into the new beta version. When a version transitions from pre-version to stable, all the changelogs of the pre-versions will be merged into the new stable version. These tasks are all handled by GitHub Actions.
1 change: 1 addition & 0 deletions dev-helper/src/widget_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ macro_rules! widget_bench {
///
/// #[test]
/// fn assert_layout_result_by_path_example(){
/// reset_test_env!();
/// let w = widget!{
/// MockBox {
/// size: Size::new(100., 100.),
Expand Down
5 changes: 5 additions & 0 deletions rclog_hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

if [ "$MERGE_CHANGELOG" = true ]; then
echo "$(rclog -t $NEW_VERSION -p ./CHANGELOG.md merge)" >| ./CHANGELOG.md
fi
1 change: 1 addition & 0 deletions static/img/release-and-branch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b94338

Please sign in to comment.