diff --git a/.github/workflows/bump-t2-bsp.yml b/.github/workflows/bump-t2-bsp.yml index f6ee6466d66..91150556de4 100644 --- a/.github/workflows/bump-t2-bsp.yml +++ b/.github/workflows/bump-t2-bsp.yml @@ -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 author: atsamd-bot 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: | diff --git a/.github/workflows/release-crates.yml b/.github/workflows/release-crates.yml index bd68114d742..285a20cb576 100644 --- a/.github/workflows/release-crates.yml +++ b/.github/workflows/release-crates.yml @@ -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 @@ -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 @@ -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