Skip to content

Commit

Permalink
github-action: run GitHub tag/release events (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored May 3, 2024
1 parent 15c6429 commit a953605
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# Takes the version of elastic-apm in the requirements.txt file and creates a tag
# Creates a new GitHub release if the version in package.json changed in the main branch and
# if the tag does not exist yet.
name: create-tag

Expand All @@ -11,7 +11,7 @@ on:
- package.json

permissions:
contents: write
contents: read

jobs:
tag:
Expand All @@ -20,10 +20,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # also fetch tags
- run: |
ELASTIC_APM_VERSION="v$(grep 'elastic/apm-rum"' package.json | cut -d":" -f2 | sed 's# "^##g' | sed 's#",##g')"
# if the tag does not exist
if [[ ! $(git tag -l "${ELASTIC_APM_VERSION}") ]]; then
git tag ${ELASTIC_APM_VERSION}
git push origin "refs/tags/${ELASTIC_APM_VERSION}"
fi

- run: make create-release
env:
GH_TOKEN: ${{ secrets.CREATE_TAG_TOKEN }}
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: release
on:
push:
branches: [ "main" ]
create:
tags: [ "v*" ]

permissions:
Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PORT ?= 3000
IMAGE ?= opbeans/opbeans-frontend
VERSION ?= latest
LTS_ALPINE ?= 12-alpine
AGENT_VERSION=$(shell grep 'elastic/apm-rum"' package.json | cut -d"^" -f2 | sed 's|",||g')

.PHONY: help
.DEFAULT_GOAL := help
Expand Down Expand Up @@ -35,3 +36,11 @@ publish: build ## Publish docker image
clean: ## Clean autogenerated files/folders
@rm -rf bats
@rm -rf target

create-release: ## Create github release given the APM Agent version if no tag release
@if [ -z "$(shell git tag -l v$(AGENT_VERSION))" ]; then \
echo "creating tag v$(AGENT_VERSION)"; \
gh release create "v$(AGENT_VERSION)" --title="$(AGENT_VERSION)" --generate-notes; \
else \
echo "git tag v$(AGENT_VERSION) already exists"; \
fi

0 comments on commit a953605

Please sign in to comment.