Handle multi-line commit messages in release-tag workflow (#315)

This commit is contained in:
Félix Saparelli 2022-06-16 10:48:28 +00:00
parent 5ee0356e34
commit e1d1940261
3 changed files with 22 additions and 8 deletions

View File

@ -5,8 +5,7 @@ on:
branches: branches:
- main - main
tags-ignore: tags-ignore:
- "cli-v*.*.*" - "*"
- "lib-v*.*.*"
jobs: jobs:
check: check:

View File

@ -6,8 +6,7 @@ on:
- staging - staging
- trying - trying
tags-ignore: tags-ignore:
- "cli-v*.*.*" - "*"
- "lib-v*.*.*"
jobs: jobs:
test: test:
@ -43,6 +42,9 @@ jobs:
profile: minimal profile: minimal
toolchain: "${{ matrix.toolchain }}" toolchain: "${{ matrix.toolchain }}"
override: true override: true
- uses: actions-rs/cargo@v1 - name: Run test suite
uses: actions-rs/cargo@v1
with: with:
command: test command: test
- name: Check that CLI runs
run: cargo run -p watchexec-cli -- -1 echo

View File

@ -3,6 +3,8 @@ on:
push: push:
branches: branches:
- main - main
tags-ignore:
- "*"
jobs: jobs:
make-tag: make-tag:
@ -15,13 +17,24 @@ jobs:
- name: Extract tag from commit message - name: Extract tag from commit message
run: | run: |
set -euxo pipefail set -euxo pipefail
message="${{ github.event.head_commit.message }}"
read -r -d '' message <<'COMMITMESSAGESEPARATOR'
${{ github.event.head_commit.message }}
COMMITMESSAGESEPARATOR
# trim both ends
message="${message#"${message%%[![:space:]]*}"}"
message="${message%"${message##*[![:space:]]}"}"
# get first line
message="$(head -n1 <<< "$message")"
crate="$(cut -d ' ' -f 2 <<< "${message}")" crate="$(cut -d ' ' -f 2 <<< "${message}")"
version="$(cut -d ' ' -f 3 <<< "${message}" | tr -d 'v')" version="$(cut -d ' ' -f 3 <<< "${message}")"
echo "CUSTOM_TAG=${crate}-${version}" >> $GITHUB_ENV echo "CUSTOM_TAG=${crate}-${version}" >> $GITHUB_ENV
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Bump version and push tag - name: Push release tag
id: tag_version id: tag_version
uses: mathieudutour/github-tag-action@v6.0 uses: mathieudutour/github-tag-action@v6.0
with: with: