diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 23be4ae38..e8d486ab3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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" diff --git a/.github/pull_request.md b/.github/pull_request.md deleted file mode 100644 index 6615a77de..000000000 --- a/.github/pull_request.md +++ /dev/null @@ -1,10 +0,0 @@ -## What does this PR do? - - - -## Checklist before merging - -- [ ] If there is a related issue, please link it in the description. -- [ ] If it is a code or documentation change, please make sure the changes are reflected in the `CHANGELOG.md` file. -- [ ] If this is a breaking change, please write one phrase about this update in the `Breaking` section of `CHANGELOG.md` file. - diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..f0fb25645 --- /dev/null +++ b/.github/pull_request_template.md @@ -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. \ No newline at end of file diff --git a/.github/workflows/alpha-release.yml b/.github/workflows/alpha-release.yml deleted file mode 100644 index 1ba4a76c8..000000000 --- a/.github/workflows/alpha-release.yml +++ /dev/null @@ -1,76 +0,0 @@ -on: - workflow_dispatch: # allows manual triggering - schedule: - - cron: "0 2 * * 2" # runs every tuesday at 00:00 -permissions: - contents: write -name: "release weekly alpha version" -jobs: - release: - runs-on: ubuntu-22.04 - steps: - - name: Exit if the branch is not master - run: | - if [[ "${{ github.ref }}" != "refs/heads/master" ]]; then - echo "Branch is not master, exiting." - exit 0 - fi - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Required to count the commits - - name: Get new commits - run: echo "NEW_COMMIT_COUNT=$(git log --oneline --since '1 week' | wc -l)" >> $GITHUB_ENV - - name: Install nightly toolchain - if: ${{ env.NEW_COMMIT_COUNT > 0 }} - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly-2023-02-01 - override: true - - name: Install cargo-release - if: ${{ env.NEW_COMMIT_COUNT > 0 }} - uses: taiki-e/install-action@v2 - with: - tool: cargo-release - - name: Cargo login - if: ${{ env.NEW_COMMIT_COUNT > 0 }} - uses: actions-rs/cargo@v1 - with: - command: login - args: ${{ secrets.CRATE_RELEASE_TOKEN }} - - name: git config - if: ${{ env.NEW_COMMIT_COUNT > 0 }} - run: | - git remote set-url origin https://${{ secrets.GITHUB_TOKEN }}@github.com/RibirX/Ribir - git config --global user.email "Adoo@outlook.com" - git config --global user.name "Bot@Ribir" - - - name: Run cargo release to publish - if: ${{ env.NEW_COMMIT_COUNT > 0 }} - uses: actions-rs/cargo@v1 - with: - command: release - args: alpha --execute --no-confirm - - name: Extract changelog - if: ${{ env.NEW_COMMIT_COUNT > 0 }} - run: | - echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - version=$(git describe --tags --abbrev=0 | grep -oP '(?<=v)\S*') - echo "VERSION=$version" >> $GITHUB_ENV - { - echo 'CHANGELOG<> $GITHUB_ENV - - name: Github release notes - if: ${{ env.NEW_COMMIT_COUNT > 0 }} - uses: ncipollo/release-action@v1 - with: - prerelease: true - body: ${{ env.CHANGELOG }} - tag: ${{ env.TAG_NAME }} \ No newline at end of file diff --git a/.github/workflows/alpha-version.yml b/.github/workflows/alpha-version.yml new file mode 100644 index 000000000..cf870f9ed --- /dev/null +++ b/.github/workflows/alpha-version.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/dispatch-other-repo.yml b/.github/workflows/dispatch-other-repo.yml new file mode 100644 index 000000000..fedf9c89f --- /dev/null +++ b/.github/workflows/dispatch-other-repo.yml @@ -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}`); + } + }); + \ No newline at end of file diff --git a/.github/workflows/new-dev-cycle.yml b/.github/workflows/new-dev-cycle.yml new file mode 100644 index 000000000..b5c7d5b17 --- /dev/null +++ b/.github/workflows/new-dev-cycle.yml @@ -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 diff --git a/.github/workflows/patch-version.yml b/.github/workflows/patch-version.yml new file mode 100644 index 000000000..2e832b438 --- /dev/null +++ b/.github/workflows/patch-version.yml @@ -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 }} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 9db74e37f..85c85c2c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,3 +93,4 @@ tokio-stream = { version = "0.1" } [workspace.metadata.release] shared-version = true tag = false +pre-release-hook = ["./rclog_hook.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 807277c3c..8c0998d96 100644 --- a/README.md +++ b/README.md @@ -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] ![](/static/img/hero-banner.png) @@ -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 diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 000000000..c4415c021 --- /dev/null +++ b/RELEASE.md @@ -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-..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-..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-..x` branch from the `master` branch. The `master` branch will then be used for the next release and will transition to the `..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. \ No newline at end of file diff --git a/dev-helper/src/widget_test.rs b/dev-helper/src/widget_test.rs index 1d8670927..5ff87a610 100644 --- a/dev-helper/src/widget_test.rs +++ b/dev-helper/src/widget_test.rs @@ -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.), diff --git a/rclog_hook.sh b/rclog_hook.sh new file mode 100644 index 000000000..be8851ae2 --- /dev/null +++ b/rclog_hook.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ "$MERGE_CHANGELOG" = true ]; then + echo "$(rclog -t $NEW_VERSION -p ./CHANGELOG.md merge)" >| ./CHANGELOG.md +fi diff --git a/static/img/release-and-branch.svg b/static/img/release-and-branch.svg new file mode 100644 index 000000000..a6965688c --- /dev/null +++ b/static/img/release-and-branch.svg @@ -0,0 +1 @@ +devmasterrelease-0.1.xfixdev0.1.1-aplha-10.1.1-beta-1dev0.1.1-rc-10.1.10.1.2release-0.1.x0.2.1-beta-10.3.1-aplha-10.2.1-aplha-1 \ No newline at end of file