Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rajrohanyadav committed Dec 6, 2024
1 parent 738b9a2 commit e6b10e4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/release-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
- prereleased
- released
tags:
- 'v*'
- "v*"

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INTEGRATION: "prometheus"
ORIGINAL_REPO_NAME: 'newrelic/nri-prometheus'
ORIGINAL_REPO_NAME: "newrelic/nri-prometheus"
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
TAG: ${{ github.event.release.tag_name }}
S3_PATH: s3://nr-downloads-main/infrastructure_agent
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: 'src/github.com/${{ env.ORIGINAL_REPO_NAME }}/go.mod'
go-version-file: "src/github.com/${{ env.ORIGINAL_REPO_NAME }}/go.mod"
- name: Running unit tests
shell: pwsh
run: |
Expand All @@ -51,7 +51,7 @@ jobs:
integration-release:
name: Use goreleaser for releasing
runs-on: ubuntu-latest
needs: [ test-nix, test-windows ]
needs: [test-nix, test-windows]
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -60,7 +60,7 @@ jobs:
- name: setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -80,17 +80,14 @@ jobs:
run: make release
env:
GENERATE_PACKAGES: true
UPLOAD_PACKAGES: ${{ github.event.release.prerelease }}
PRERELEASE: ${{ github.event.release.prerelease }}
- name: release fips
# FIPS packages need to be built in the fips container
# TODO: It should be refactored when we change the way docker images are being built
run: make ci/prerelease-fips
env:
GENERATE_PACKAGES: true
UPLOAD_PACKAGES: ${{ github.event.release.prerelease }}
GPG_MAIL: '[email protected]'
# The upload script expects this to authenticate.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRERELEASE: ${{ github.event.release.prerelease }}

- if: ${{ github.event.release.prerelease }}
name: Update title for successful pre-release
Expand All @@ -99,7 +96,6 @@ jobs:
run: |
gh release edit ${{ github.event.release.tag_name }} --title "${{ github.event.release.tag_name }}"
notify-failure:
if: ${{ always() && failure() }}
needs: [test-nix, test-windows, integration-release]
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser-fips.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ builds:
main: ./cmd/nri-prometheus/
binary: nri-prometheus
ldflags:
- -s -w -X github.com/newrelic/nri-prometheus/internal/integration.Version={{.Version}} #-X main.gitCommit={{.Commit}} -X main.buildDate={{.Date}}
- -s -w -X github.com/newrelic/nri-prometheus/internal/integration.Version={{.Version}}
env:
- CGO_ENABLED=1
- GOEXPERIMENT=boringcrypto
Expand Down
2 changes: 1 addition & 1 deletion build/ci.mk
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ifdef TAG
-e TAG \
-e TAG_SUFFIX \
-e GENERATE_PACKAGES \
-e UPLOAD_PACKAGES \
-e PRERELEASE \
$(BUILDER_IMAGE) make release-fips
else
@echo "===> $(INTEGRATION) === [ci/prerelease] TAG env variable expected to be set"
Expand Down
22 changes: 10 additions & 12 deletions build/release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ifeq ($(GENERATE_PACKAGES), true)
# TAG_SUFFIX should be set as "-pre" during prereleases
@$(GORELEASER_BIN) release --config $(CURDIR)/.goreleaser-fips.yml --skip=validate --clean
else
@echo "===> $(INTEGRATION) === [release/build] build compiling fips binaries"
@echo "===> $(INTEGRATION) === [release/build-fips] build compiling fips binaries"
# release/build with PRERELEASE unset is actually called only from push/pr pipeline to check everything builds correctly
@$(GORELEASER_BIN) build --config $(CURDIR)/.goreleaser-fips.yml --skip=validate --snapshot --clean
endif
Expand All @@ -59,31 +59,29 @@ release/fix-archive:

.PHONY : release/publish
release/publish:
ifeq ($(UPLOAD_PACKAGES), true)
ifeq ($(PRERELEASE), true)
@echo "===> $(INTEGRATION) === [release/publish] publishing packages"
# REPO_FULL_NAME here is only necessary for forks. It can be removed when this is merged into the original repo
@bash $(CURDIR)/build/upload_artifacts_gh.sh $(REPO_FULL_NAME)
@bash $(CURDIR)/build/upload_artifacts_gh.sh
endif
@echo "===> $(INTEGRATION) === [release/publish] publishing manifests"
@echo "===> $(INTEGRATION) === [release/publish] compiling binaries"
@$(GORELEASER_BIN) build --config $(CURDIR)/.goreleaser.yml --skip=validate --snapshot --clean

.PHONY : release/publish-fips
release/publish-fips:
ifeq ($(UPLOAD_PACKAGES), true)
@echo "===> $(INTEGRATION) === [release/publish] publishing packages"
# REPO_FULL_NAME here is only necessary for forks. It can be removed when this is merged into the original repo
@bash $(CURDIR)/build/upload_artifacts_gh.sh $(REPO_FULL_NAME)
ifeq ($(PRERELEASE), true)
@echo "===> $(INTEGRATION) === [release/publish-fips] publishing fips packages"
@bash $(CURDIR)/build/upload_artifacts_gh.sh
endif
@echo "===> $(INTEGRATION) === [release/publish] publishing manifests"
@echo "===> $(INTEGRATION) === [release/publish-fips] compiling fips binaries"
@$(GORELEASER_BIN) build --config $(CURDIR)/.goreleaser-fips.yml --skip=validate --snapshot --clean

.PHONY : release
release: release/build release/fix-archive release/publish release/clean
@echo "===> $(INTEGRATION) === [release/publish] full pre-release cycle complete for nix"
@echo "===> $(INTEGRATION) === [release] full pre-release cycle complete for nix"

.PHONY : release-fips
release-fips: release/build-fips release/fix-archive release/publish-fips release/clean
@echo "===> $(INTEGRATION) === [release/publish] fips pre-release cycle complete for nix"
@echo "===> $(INTEGRATION) === [release-fips] fips pre-release cycle complete for nix"

OS := $(shell uname -s)
ifeq ($(OS), Darwin)
Expand Down

0 comments on commit e6b10e4

Please sign in to comment.