606: GHA: Automatic merge to release/vX r=perlindgren a=AfoHT

- Require clippy for deploy
- GHA: Automatic merge to release/vX
- Link dev-book to stable if they are describe the same release
- Update CHANGELOG

Development work is done in the master branch

Older versions previously were found in v0.5.x, v0.4.x branches.
Now with v1 released, and any breaking change forcing a v2,
a need to streamline documentation building arose.

The different docs:

- rtic.rs
  - latest stable (v1)
    - API documentation
    - RTIC book
  - old stable (v0.5)
    - API documentation
    - RTIC book
  - oldold stable (v0.4)
    - API documentation
    - RTIC book

- docs.rs
  - all previous crates.io releases
    - API documentation

With this PR, when a pull request gets merged to master
with CI passing the current master branch gets merged
to `release/v$VERSION` where `$VERSION` is parsed from
cargo metadata of cortex-m-rtic.

The deployment of docs GHA job is dependent on this merge job,
and therefore the docs published to rtic.rs will contain the latest
content from the merged PR.

Assuming the current situation where `v1` is the latest stable,
a PR should trigger a merge to `release/v1` and then docs gets pushed
to `gh-pages` branch (rtic.rs).

For the future, when the latest stable is still `v1`, but the current
dev version in `master` branch is `v2` the GHA job will push to `release/v2` (dev branch).

For the future we might decide if this push of the dev branch is desirable.

If the current stable version and dev version share the same major version,
the dev book redirection on rtic.rs will point to the stable book instead.


Co-authored-by: Henrik Tjäder <henrik@grepit.se>
This commit is contained in:
bors[bot] 2022-02-10 08:58:34 +00:00 committed by GitHub
commit a11cba66d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 10 deletions

View file

@ -363,13 +363,16 @@ jobs:
linkchecker $td/book/en/ linkchecker $td/book/en/
linkchecker $td/book/ru/ linkchecker $td/book/ru/
# Only runs when pushing to master branch # Update stable branch
deploy: #
name: deploy # This needs to run before book is built
mergetostablebranch:
name: If CI passes, merge master branch into release/vX
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: needs:
- style - style
- check - check
- clippy
- checkexamples - checkexamples
- testexamples - testexamples
- checkmacros - checkmacros
@ -377,6 +380,39 @@ jobs:
- tests - tests
- docs - docs
- mdbook - mdbook
# Only run this when pushing to master branch
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Get crate version and print output branch release/vX
id: crateversionbranch
# Parse metadata for version number, extract the Semver Major
run: |
VERSION=$(cargo metadata --format-version 1 --no-deps --offline | jq -r '.packages[] | select(.name =="cortex-m-rtic") | .version')
VERSIONMAJOR=${VERSION%.*.*}
echo "branch=release/v$VERSIONMAJOR" >> $GITHUB_ENV
echo "versionmajor=$VERSIONMAJOR" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_ENV
- uses: everlytic/branch-merge@1.1.2
with:
github_token: ${{ github.token }}
source_ref: 'master'
target_branch: ${{ env.branch }}
commit_message_template: '[Bors] Merged {source_ref} into target {target_branch}'
# Only runs when pushing to master branch
# Bors run CI against staging branch,
# if that succeeds Borst tries against master branch
# If all tests pass, then deploy stage is run
deploy:
name: deploy
runs-on: ubuntu-20.04
needs:
mergetostablebranch
# Only run this when pushing to master branch # Only run this when pushing to master branch
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
steps: steps:
@ -399,6 +435,16 @@ jobs:
with: with:
mdbook-version: 'latest' mdbook-version: 'latest'
- name: Get crate version
id: crateversion
# Parse metadata for version number, extract the Semver Major
run: |
VERSION=$(cargo metadata --format-version 1 --no-deps --offline | jq -r '.packages[] | select(.name =="cortex-m-rtic") | .version')
VERSIONMAJOR=${VERSION%.*.*}
echo "branch=release/v$VERSIONMAJOR" >> $GITHUB_ENV
echo "versionmajor=$VERSIONMAJOR" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_ENV
- name: Remove cargo-config - name: Remove cargo-config
run: rm -f .cargo/config run: rm -f .cargo/config
@ -411,12 +457,12 @@ jobs:
langs=( en ru ) langs=( en ru )
devver=( dev ) devver=( dev )
# The latest stable must be the first element in the array # The latest stable must be the first element in the array
vers=( 1.0.x 0.5.x 0.4.x ) vers=( "1" "0.5" "0.4" )
# All releases start with "v" # All releases start with "v"
# followed by MAJOR.MINOR.PATCH, see semver.org # followed by MAJOR.MINOR.PATCH, see semver.org
# Retain MAJOR.MINOR as $stable # Store first in array as stable
stable=${vers%.*} stable=${vers}
echo "Stable version: $stable" echo "Stable version: $stable"
@ -433,8 +479,18 @@ jobs:
sed "s|URL|$stable|g" redirect.html > $td/index.html sed "s|URL|$stable|g" redirect.html > $td/index.html
# Create the redirects for dev-version # Create the redirects for dev-version
# If the current stable and the version being built differ,
# then there is a dev-version and the links should point to it.
if [[ "$stable" != "{{ env.versionmajor }}" ]];
then
sed 's|URL|rtic/index.html|g' redirect.html > $td/$devver/api/index.html sed 's|URL|rtic/index.html|g' redirect.html > $td/$devver/api/index.html
sed 's|URL|book/en|g' redirect.html > $td/$devver/index.html sed 's|URL|book/en|g' redirect.html > $td/$devver/index.html
else
# If the current stable and the "dev" version in master branch
# share the same major version, redirect dev/ to stable book
sed 's|URL|rtic.rs/$stable/api/rtic|g' redirect.html > $td/$devver/api/index.html
sed 's|URL|rtic.rs/$stable|g' redirect.html > $td/$devver/index.html
fi
# Build books # Build books
for lang in ${langs[@]}; do for lang in ${langs[@]}; do
@ -448,11 +504,11 @@ jobs:
# Build older versions, including stable # Build older versions, including stable
root=$(pwd) root=$(pwd)
for ver in ${vers[@]}; do for ver in ${vers[@]}; do
prefix=${ver%.*} prefix=${ver}
mkdir -p $td/$prefix/book mkdir -p $td/$prefix/book
src=$(mktemp -d) src=$(mktemp -d)
curl -L https://github.com/rtic-rs/cortex-m-rtic/archive/v${ver}.tar.gz | tar xz --strip-components 1 -C $src curl -L https://github.com/rtic-rs/cortex-m-rtic/archive/release/v${ver}.tar.gz | tar xz --strip-components 1 -C $src
pushd $src pushd $src
rm -f .cargo/config rm -f .cargo/config

View file

@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added ### Added
- If current $stable and master version matches, dev-book redirects to $stable book
- During deploy stage, merge master branch into current stable IFF cargo package version matches
- Rework branch structure, release/vVERSION
- Cargo clippy in CI - Cargo clippy in CI
- Use rust-cache Github Action - Use rust-cache Github Action
- CI changelog entry enforcer - CI changelog entry enforcer