From d51816140995f48e509f090093ffa201656c2670 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 30 Apr 2024 13:12:14 +0200 Subject: [PATCH 1/3] use PAT to support GitHub events --- .github/workflows/create-tag.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 9de94b9..28261aa 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -18,6 +18,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # also fetch tags + - uses: elastic/apm-pipeline-library/.github/actions/setup-git@current + with: + # This should help with running GitHub events + token: ${{ secrets.CREATE_TAG_TOKEN }} - uses: actions/setup-node@v4 with: node-version: '20' From 0d69d1a725669cdb05b40dac16987ad938f4c0c5 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 30 Apr 2024 13:15:48 +0200 Subject: [PATCH 2/3] faster --- .github/workflows/create-tag.yml | 14 +++----------- Makefile | 10 ++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 28261aa..78c262d 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -22,18 +22,10 @@ jobs: with: # This should help with running GitHub events token: ${{ secrets.CREATE_TAG_TOKEN }} + - 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-tag diff --git a/Makefile b/Makefile index 592e630..850f4c5 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ PORT ?= 3000 IMAGE ?= opbeans/opbeans-node VERSION ?= latest LTS_ALPINE ?= 20-alpine +AGENT_VERSION=v$(shell npm ls --package-lock-only elastic-apm-node --json | jq -r '.dependencies."elastic-apm-node".version') .DEFAULT_GOAL := help @@ -34,3 +35,12 @@ publish: build ## Publish docker image clean: ## Clean autogenerated files/folders @rm -rf bats @rm -rf target + +create-tag: ## Create git tag given the APM Agent version + @if [ -z "$(shell git tag -l "$(AGENT_VERSION)")" ]; then \ + echo "creating tag $(AGENT_VERSION)"; \ + git tag $(AGENT_VERSION); \ + git push origin "refs/tags/$(AGENT_VERSION)"; \ + else \ + echo "git tag $(AGENT_VERSION) already exists"; \ + fi From 2fff4ad76dd82edceb528404ea5abd29a363bdff Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 30 Apr 2024 13:36:49 +0200 Subject: [PATCH 3/3] use gh release instead --- .github/workflows/create-tag.yml | 17 ++++++----------- Makefile | 11 +++++------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 78c262d..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,14 +20,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # also fetch tags - - uses: elastic/apm-pipeline-library/.github/actions/setup-git@current - with: - # This should help with running GitHub events - token: ${{ secrets.CREATE_TAG_TOKEN }} - - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - - run: make create-tag + - run: make create-release + env: + GH_TOKEN: ${{ secrets.CREATE_TAG_TOKEN }} diff --git a/Makefile b/Makefile index 850f4c5..3953695 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PORT ?= 3000 IMAGE ?= opbeans/opbeans-node VERSION ?= latest LTS_ALPINE ?= 20-alpine -AGENT_VERSION=v$(shell npm ls --package-lock-only elastic-apm-node --json | jq -r '.dependencies."elastic-apm-node".version') +AGENT_VERSION=$(shell npm ls --package-lock-only elastic-apm-node --json | jq -r '.dependencies."elastic-apm-node".version') .DEFAULT_GOAL := help @@ -36,11 +36,10 @@ clean: ## Clean autogenerated files/folders @rm -rf bats @rm -rf target -create-tag: ## Create git tag given the APM Agent version - @if [ -z "$(shell git tag -l "$(AGENT_VERSION)")" ]; then \ - echo "creating tag $(AGENT_VERSION)"; \ - git tag $(AGENT_VERSION); \ - git push origin "refs/tags/$(AGENT_VERSION)"; \ +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