Skip to content

Commit

Permalink
github-action: create git release/tag (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Apr 30, 2024
1 parent 946c002 commit 3e100ee
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# Creates a new GitHub release if the version in go.mod changed in the main branch and
# if the tag does not exist yet.
name: create-tag

on:
push:
branches:
- main
paths:
- go.mod

permissions:
contents: read

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # also fetch tags

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- run: make create-release
env:
GH_TOKEN: ${{ secrets.CREATE_TAG_TOKEN }}
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PORT ?= 8000
IMAGE ?= opbeans/opbeans-go
VERSION ?= latest
LTS_ALPINE ?= 12-alpine
AGENT_VERSION=$(shell go list -f '{{.Version}}' -m go.elastic.co/apm/v2)

.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 $(AGENT_VERSION))" ]; then \
echo "creating tag $(AGENT_VERSION)"; \
gh release create "$(AGENT_VERSION)" --title="$(AGENT_VERSION)" --generate-notes; \
else \
echo "git tag $(AGENT_VERSION) already exists"; \
fi

0 comments on commit 3e100ee

Please sign in to comment.