Skip to content

Commit 7ce8e7a

Browse files
authored
github-action: run GitHub tag/release events (#221)
1 parent 4fa6ded commit 7ce8e7a

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

.github/workflows/create-tag.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
# Takes the version of elastic-apm in the Gemfile and creates a tag
2+
# Creates a new GitHub release if the version in Gemfile changed in the main branch and
33
# if the tag does not exist yet.
44
name: create-tag
55

@@ -11,7 +11,7 @@ on:
1111
- Gemfile
1212

1313
permissions:
14-
contents: write
14+
contents: read
1515

1616
jobs:
1717
tag:
@@ -20,10 +20,7 @@ jobs:
2020
- uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0 # also fetch tags
23-
- run: |
24-
ELASTIC_APM_VERSION="v$(cat Gemfile | grep elastic-apm | awk 'BEGIN { FS=", " } { print $2 }' | tr -d \')"
25-
# if the tag does not exist
26-
if [[ ! $(git tag -l "${ELASTIC_APM_VERSION}") ]]; then
27-
git tag ${ELASTIC_APM_VERSION}
28-
git push origin "refs/tags/${ELASTIC_APM_VERSION}"
29-
fi
23+
24+
- run: make create-release
25+
env:
26+
GH_TOKEN: ${{ secrets.CREATE_TAG_TOKEN }}

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: release
33
on:
44
push:
55
branches: [ "main" ]
6-
create:
76
tags: [ "v*" ]
87

98
permissions:

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PORT ?= 3000
22
IMAGE ?= opbeans/opbeans-ruby
33
VERSION ?= latest
44
LTS_ALPINE ?= 12-alpine
5+
AGENT_VERSION=$(shell grep "elastic-apm" Gemfile | sed 's|.*, ||g' | tr -d \')
56

67
.PHONY: help
78
.DEFAULT_GOAL := help
@@ -35,3 +36,11 @@ publish: build ## Publish docker image
3536
clean: ## Clean autogenerated files/folders
3637
@rm -rf bats
3738
@rm -rf target
39+
40+
create-release: ## Create github release given the APM Agent version if no tag release
41+
@if [ -z "$(shell git tag -l v$(AGENT_VERSION))" ]; then \
42+
echo "creating tag v$(AGENT_VERSION)"; \
43+
gh release create "v$(AGENT_VERSION)" --title="$(AGENT_VERSION)" --generate-notes; \
44+
else \
45+
echo "git tag v$(AGENT_VERSION) already exists"; \
46+
fi

0 commit comments

Comments
 (0)