43 lines
1.3 KiB
YAML
43 lines
1.3 KiB
YAML
name: Tag a release
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags-ignore:
|
|
- "*"
|
|
|
|
jobs:
|
|
make-tag:
|
|
runs-on: ubuntu-latest
|
|
# because only bors can push to main, and it squashes, only PRs
|
|
# that are named `release: {crate-name} v{version}` will get tagged!
|
|
# the commit message will look like: `release: {crate-name} v{version} (#{pr-number})`
|
|
if: "startsWith(github.event.head_commit.message, 'release: ')"
|
|
steps:
|
|
- name: Extract tag from commit message
|
|
run: |
|
|
set -euxo pipefail
|
|
|
|
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}")"
|
|
version="$(cut -d ' ' -f 3 <<< "${message}")"
|
|
echo "CUSTOM_TAG=${crate}-${version}" >> $GITHUB_ENV
|
|
|
|
- uses: actions/checkout@v2
|
|
- name: Push release tag
|
|
id: tag_version
|
|
uses: mathieudutour/github-tag-action@v6.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
custom_tag: ${{ env.CUSTOM_TAG }}
|