[gh action] Release on tag push
This commit is contained in:
parent
3b4a86aea4
commit
fb910e063c
@ -1,10 +1,10 @@
|
||||
FROM debian:stable-slim
|
||||
|
||||
LABEL "name"="filter"
|
||||
LABEL "version"="1.1.0"
|
||||
LABEL "name"="commit-matches-branch"
|
||||
LABEL "version"="1.0.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.name"="Commit matches branch"
|
||||
LABEL "com.github.actions.description"="Only continue the workflow if the current commit is the last commit of the given branch"
|
||||
LABEL "com.github.actions.icon"="filter"
|
||||
LABEL "com.github.actions.color"="gray-dark"
|
||||
|
||||
13
.github/actions/commit-matches-branch/entrypoint.sh
vendored
Normal file
13
.github/actions/commit-matches-branch/entrypoint.sh
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
current=$(git rev-parse HEAD)
|
||||
git checkout $1
|
||||
branch=$(git rev-parse HEAD)
|
||||
|
||||
if [ "$current" = "$branch" ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 78
|
||||
fi
|
||||
16
.github/actions/create-release-tag/Dockerfile
vendored
16
.github/actions/create-release-tag/Dockerfile
vendored
@ -1,16 +0,0 @@
|
||||
FROM debian:stable-slim
|
||||
|
||||
LABEL "name"="create-release-tag"
|
||||
LABEL "version"="0.0.1"
|
||||
|
||||
LABEL "com.github.actions.name"="Create release tag"
|
||||
LABEL "com.github.actions.description"="Creates a release tag equal to the last commit message"
|
||||
LABEL "com.github.actions.icon"="tag"
|
||||
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"]
|
||||
14
.github/actions/create-release-tag/entrypoint.sh
vendored
14
.github/actions/create-release-tag/entrypoint.sh
vendored
@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# 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..."
|
||||
tag_name=$(git log --oneline --format=%B -1 $GITHUB_SHA)
|
||||
|
||||
echo "INFO: Creating new tag..."
|
||||
(git tag $tag_name $GITHUB_SHA) || echo "INFO: Tag already exists"
|
||||
@ -1,15 +0,0 @@
|
||||
#!/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
|
||||
20
.github/main.workflow
vendored
20
.github/main.workflow
vendored
@ -1,18 +1,23 @@
|
||||
workflow "Release" {
|
||||
resolves = [
|
||||
"Trigger GitHub release",
|
||||
"Is version tag",
|
||||
]
|
||||
on = "release"
|
||||
on = "push"
|
||||
resolves = ["Trigger GitHub release"]
|
||||
}
|
||||
|
||||
action "Is version tag" {
|
||||
uses = "actions/bin/filter@master"
|
||||
uses = "actions/bin/filter@0dbb077f64d0ec1068a644d25c71b1db66148a24"
|
||||
args = "tag v*"
|
||||
}
|
||||
|
||||
action "Is tag from master" {
|
||||
uses = "./commit-matches-branch/"
|
||||
needs = [
|
||||
"Is version tag",
|
||||
]
|
||||
args = "master"
|
||||
}
|
||||
|
||||
action "Trigger GitHub release" {
|
||||
uses = "./.github/actions/trigger-github-release/"
|
||||
uses = "./trigger-github-release/"
|
||||
secrets = ["GITHUB_TOKEN"]
|
||||
env = {
|
||||
COMMIT_AUTHOR_NAME = "Babel Bot"
|
||||
@ -20,6 +25,7 @@ action "Trigger GitHub release" {
|
||||
}
|
||||
needs = [
|
||||
"Is version tag",
|
||||
"Is tag from master",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user