Skip to content

Commit

Permalink
CI improvements (continued) (#759)
Browse files Browse the repository at this point in the history
* CI: Fix typo in bump-t2-bsp workflow

* Tag all published crates

---------

Co-authored-by: Ian Rees <[email protected]>
  • Loading branch information
jbeaurivage and ianrrees authored Sep 12, 2024
1 parent c497239 commit cbbd4f0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/bump-t2-bsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ jobs:
uses: peter-evans/create-pull-request@v6
with:
commit-message: |
Bump ${{ github.event.input.bsp_name }} (${{ github.event.inputs.bsp_bump }})
Bump ${{ github.event.inputs.bsp_name }} (${{ github.event.inputs.bsp_bump }})
committer: GitHub <[email protected]>
author: atsamd-bot <[email protected]>
signoff: false
branch: bump-${{ github.event.input.bsp_name }}
branch: bump-${{ github.event.inputs.bsp_name }}
delete-branch: true
title: '[atsamd-bot] Bump crate versions'
body: |
Expand Down
57 changes: 53 additions & 4 deletions .github/workflows/release-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,31 @@ jobs:
#
# All errors start with the form 'error: ', so we detect that and
# bail the subshell to crash out on other publish errors.
#
# Before publishing, we also tag each PAC with its current version.
# If creating+pushing the tag fails, we check if there already is an
# identical tag at the same commit, and continue processing if that's
# the case. If tagging fails for any other reason, bail the subshell.
for d in pac/*/
do
(
cd "${d}"
PAC_NAME="${d#pac/}"
PAC_NAME="${PAC_NAME%/}"
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
TAG_NAME="${PAC_NAME}-${VERSION}"
if ! git tag -a $TAG_NAME -m "${PAC_NAME} release ${VERSION}" && git push origin tag "$TAG_NAME"; then
if git tag --points-at "$(git rev-parse HEAD)" | grep "$TAG_NAME" > /dev/null; then
echo '(and points at this commit). Continuing.'
else
false
fi
fi
set +e
PUBLISH_ERR=$(cargo publish 2>&1 >/dev/null)
set -e
Expand All @@ -79,11 +99,23 @@ jobs:
# Force update of the registry
cargo update || true
cd "hal" && cargo publish --no-verify
cd hal
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
TAG_NAME="atsamd-hal-${VERSION}"
# Create+push a git tag. If that fails, check if an identical tag already exists at the
# same commit. Bail otherwise.
if ! git tag -a $TAG_NAME -m "atsamd-hal release ${VERSION}" && git push origin tag "$TAG_NAME"; then
if git tag --points-at "$(git rev-parse HEAD)" | grep "$TAG_NAME" > /dev/null; then
echo '(and points at this commit). Continuing.'
else
false
fi
fi
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
git tag -a "v${version}" -m "atsamd-hal release v${version}"
git push origin tag "v${version}"
cargo publish
- name: Release BSP crates
Expand All @@ -108,11 +140,28 @@ jobs:
#
# All errors start with the form 'error: ', so we detect that and
# bail the subshell to crash out on other publish errors.
#
# Before publishing, we also tag each BSP with its current version.
# If creating+pushing the tag fails, we check if there already is an
# identical tag at the same commit, and continue processing if that's
# the case. If tagging fails for any other reason, bail the subshell.
for bsp in $(cat crates.json | jq -Mr -c '.boards | keys[]');
do
(
cd "boards/${bsp}"
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
TAG_NAME="${bsp}-${VERSION}"
if ! git tag -a $TAG_NAME -m "${bsp} release ${VERSION}" && git push origin tag "$TAG_NAME"; then
if git tag --points-at "$(git rev-parse HEAD)" | grep "$TAG_NAME" > /dev/null; then
echo '(and points at this commit). Continuing.'
else
false
fi
fi
set +e
PUBLISH_ERR=$(cargo publish 2>&1 >/dev/null)
set -e
Expand Down

0 comments on commit cbbd4f0

Please sign in to comment.