diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 9de94b9..e2a11ab 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -7,9 +7,11 @@ on: push: branches: - main + paths: + - package.json permissions: - contents: write + contents: read jobs: tag: @@ -18,18 +20,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # also fetch tags - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - - name: Install dependencies # This is needed to be able to run the npm list command - run: npm ci - - run: | - ELASTIC_APM_NODE_VERSION=$(npm list --depth 0 --json elastic-apm-node | jq -r '.dependencies."elastic-apm-node".version') - ELASTIC_APM_NODE_VERSION_WITH_PREFIX="v${ELASTIC_APM_NODE_VERSION}" - # if the tag does not exist - if [[ ! $(git tag -l "${ELASTIC_APM_NODE_VERSION_WITH_PREFIX}") ]]; then - git tag ${ELASTIC_APM_NODE_VERSION_WITH_PREFIX} - git push origin "refs/tags/${ELASTIC_APM_NODE_VERSION_WITH_PREFIX}" - fi - + + - run: make create-release + env: + GH_TOKEN: ${{ secrets.CREATE_TAG_TOKEN }} diff --git a/Makefile b/Makefile index 592e630..3953695 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ PORT ?= 3000 IMAGE ?= opbeans/opbeans-node VERSION ?= latest LTS_ALPINE ?= 20-alpine +AGENT_VERSION=$(shell npm ls --package-lock-only elastic-apm-node --json | jq -r '.dependencies."elastic-apm-node".version') .DEFAULT_GOAL := help @@ -34,3 +35,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 $(AGENT_VERSION) already exists"; \ + fi