From 78bdab6bf1d840ef6b072261ea33d2b8d1ad3d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 19:23:26 +0100 Subject: [PATCH 1/4] Require clippy for deploy --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d69740ba16..976e698a47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -370,6 +370,7 @@ jobs: needs: - style - check + - clippy - checkexamples - testexamples - checkmacros From 4a7951121db71ff075bf5a8eb2cb3760c65ace7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 21:03:57 +0100 Subject: [PATCH 2/4] GHA: Automatic merge to release/vX --- .github/workflows/build.yml | 61 ++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 976e698a47..9d61cc0f08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -363,9 +363,11 @@ jobs: linkchecker $td/book/en/ linkchecker $td/book/ru/ - # Only runs when pushing to master branch - deploy: - name: deploy + # Update stable branch + # + # This needs to run before book is built + mergetostablebranch: + name: If CI passes, merge master branch into release/vX runs-on: ubuntu-20.04 needs: - style @@ -378,6 +380,39 @@ jobs: - tests - docs - 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 if: github.ref == 'refs/heads/master' steps: @@ -400,6 +435,16 @@ jobs: with: 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 run: rm -f .cargo/config @@ -412,12 +457,12 @@ jobs: langs=( en ru ) devver=( dev ) # 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" # followed by MAJOR.MINOR.PATCH, see semver.org - # Retain MAJOR.MINOR as $stable - stable=${vers%.*} + # Store first in array as stable + stable=${vers} echo "Stable version: $stable" @@ -449,11 +494,11 @@ jobs: # Build older versions, including stable root=$(pwd) for ver in ${vers[@]}; do - prefix=${ver%.*} + prefix=${ver} mkdir -p $td/$prefix/book 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 rm -f .cargo/config From 780b3672ca219196a6e990b4fa6590815537e374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 21:52:05 +0100 Subject: [PATCH 3/4] Link dev-book to stable if they are describe the same release --- .github/workflows/build.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d61cc0f08..923c30f15a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -479,8 +479,18 @@ jobs: sed "s|URL|$stable|g" redirect.html > $td/index.html # Create the redirects for dev-version - 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 + # 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|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 for lang in ${langs[@]}; do From 4d3758a6b2c391cf4c06fbafa02a1b79cc82abae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 22:18:17 +0100 Subject: [PATCH 4/4] Update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e16bb75c2c..0d30960b0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### 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 - Use rust-cache Github Action - CI changelog entry enforcer