Create a new release after a v*.*.* commit instead of the tag (#9470)
* Create a new release after a v*.*.* commit instead of the tag * Fix bugs * Avoid matching things like "v2"
This commit is contained in:
parent
83cbc11d46
commit
b25fea49fe
16
.github/actions/filter-commit-message/Dockerfile
vendored
Normal file
16
.github/actions/filter-commit-message/Dockerfile
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM debian:stable-slim
|
||||||
|
|
||||||
|
LABEL "name"="filter"
|
||||||
|
LABEL "version"="1.1.0"
|
||||||
|
|
||||||
|
LABEL "com.github.actions.name"="Filter commit message"
|
||||||
|
LABEL "com.github.actions.description"="Stop a workflow if the message of the current commit doesn't match the pattern"
|
||||||
|
LABEL "com.github.actions.icon"="filter"
|
||||||
|
LABEL "com.github.actions.color"="gray-dark"
|
||||||
|
|
||||||
|
ADD entrypoint.sh /action/entrypoint.sh
|
||||||
|
|
||||||
|
RUN chmod +x /action/entrypoint.sh
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends git
|
||||||
|
|
||||||
|
ENTRYPOINT ["/action/entrypoint.sh"]
|
||||||
15
.github/actions/filter-commit-message/entrypoint.sh
vendored
Normal file
15
.github/actions/filter-commit-message/entrypoint.sh
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
pattern=$1
|
||||||
|
message=$(git log --oneline --format=%B -1 $GITHUB_SHA)
|
||||||
|
|
||||||
|
if echo "$message" | grep -Pq "$pattern"; then
|
||||||
|
echo "INFO: $message matches $pattern"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "INFO: $message does not match $pattern"
|
||||||
|
# 78 is the "neutral" exit status
|
||||||
|
exit 78
|
||||||
|
fi
|
||||||
@ -5,11 +5,20 @@ set -e
|
|||||||
echo "INFO: Installing action dependencies..."
|
echo "INFO: Installing action dependencies..."
|
||||||
(cd /action; npm ci)
|
(cd /action; npm ci)
|
||||||
|
|
||||||
echo "INFO: Checking out current tag..."
|
echo "INFO: Checking out current commit..."
|
||||||
git -c advice.detachedHead=false checkout $GITHUB_REF
|
git -c advice.detachedHead=false checkout $GITHUB_SHA
|
||||||
|
|
||||||
|
# GitHub doesn't support running actions on new tags yet: we need to run it on the commit.
|
||||||
|
# For this reason, we can't be sure that the tag already exists. We can use the commit
|
||||||
|
# message to create the tag. If the tag already exists locally, they won't conflict because
|
||||||
|
# they have the same name and are on the same commit.
|
||||||
|
echo "INFO: Getting release version..."
|
||||||
|
# current_tag=$(git describe --abbrev=0 --tags HEAD)
|
||||||
|
current_tag=$(git log --oneline --format=%B -1 HEAD)
|
||||||
|
|
||||||
|
echo "INFO: Creating new tag..."
|
||||||
|
(git tag $current_tag $GITHUB_SHA) || echo "INFO: Tag already exists"
|
||||||
|
|
||||||
echo "INFO: Getting tag info..."
|
|
||||||
current_tag=$(git describe --abbrev=0 --tags)
|
|
||||||
last_tag=$(git describe --abbrev=0 --tags HEAD^)
|
last_tag=$(git describe --abbrev=0 --tags HEAD^)
|
||||||
echo "INFO: New version is $current_tag; last version is $last_tag."
|
echo "INFO: New version is $current_tag; last version is $last_tag."
|
||||||
|
|
||||||
|
|||||||
10
.github/main.workflow
vendored
10
.github/main.workflow
vendored
@ -10,14 +10,16 @@ action "Trigger GitHub release" {
|
|||||||
# When GitHub Actions will support the "release" event for public
|
# When GitHub Actions will support the "release" event for public
|
||||||
# repositories, we won't need these checks anymore.
|
# repositories, we won't need these checks anymore.
|
||||||
needs = [
|
needs = [
|
||||||
"Is version tag",
|
"Is version commit",
|
||||||
"On master branch",
|
"On master branch",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
action "Is version tag" {
|
action "Is version commit" {
|
||||||
uses = "actions/bin/filter@master"
|
uses = "./.github/actions/filter-commit-message"
|
||||||
args = "tag v*"
|
# This regex is run using "grep -P".
|
||||||
|
# The (-\\S+) part is for 7.0.0-beta.1 releases.
|
||||||
|
args = "^v(\\d+\\.){2}\\d+(-\\S+)?$"
|
||||||
}
|
}
|
||||||
|
|
||||||
action "On master branch" {
|
action "On master branch" {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user