diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f04da88..e830098 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,11 +16,11 @@ on: required: true default: current -#env: -# DOCKER_USR: ${{ secrets.DOCKER_USR }} +env: + UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} jobs: - test: + build: runs-on: ubuntu-22.04 steps: - name: Checkout @@ -34,19 +34,20 @@ jobs: command: -h - name: Build xpkg - run: make output + run: make build env: CROSSPLANE: './crossplane' -# - name: Login to Docker -# uses: docker/login-action@v3 -# if: env.DOCKER_USR != '' -# with: -# registry: registry.upbound.io -# username: ${{ secrets.DOCKER_USR }} -# password: ${{ secrets.DOCKER_PSW }} + - name: Login to Upbound + uses: docker/login-action@v3 + if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != '' + with: + registry: xpkg.upbound.io + username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} + password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} -# - name: Push xpkg -# uses: crossplane-contrib/xpkg-action@master -# with: -# command: push configuration -f test/xpkg-action-test/xpkg-action-test.xpkg registry.upbound.io/crossplane-test/xpkg-action-test:v0.0.1 + - name: Push xpkg + run: make push + if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != '' + env: + CROSSPLANE: './crossplane' diff --git a/Makefile b/Makefile index 56f640c..8572d8f 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ generator/crds.yaml: curl -sLO https://github.com/grafana/crossplane-provider-grafana/releases/download/v$(PROVIDER_VERSION)/crds.yaml grafanaplane/raw.libsonnet: generator/main.libsonnet generator/namespaced.libsonnet generator/crds.yaml $(VENDOR_DEPTHS) + rm -rf grafanaplane/raw && \ FILES=$$($(JSONNET_BIN) \ -S -c -m grafanaplane \ -J generator/vendor \ @@ -21,17 +22,20 @@ grafanaplane/raw.libsonnet: generator/main.libsonnet generator/namespaced.libson grafanaplane/compositions.libsonnet: generator/compositions.libsonnet generator/namespaced.libsonnet generator/crds.yaml $(VENDOR_DEPTHS) $(JSONNET_BIN) \ - -J generator/vendor generator/compositions.libsonnet \ - -A 'configurationVersion=$(LIBRARY_VERSION)-$(PROVIDER_VERSION)'| \ + -J generator/vendor \ + -A 'configurationVersion=$(LIBRARY_VERSION)-$(PROVIDER_VERSION)' \ + generator/compositions.libsonnet | \ jsonnetfmt - > grafanaplane/compositions.libsonnet packages: generator/packages.libsonnet generator/namespaced.libsonnet generator/crds.yaml $(VENDOR_DEPTHS) + rm -rf packages && \ $(JSONNET_BIN) -S -m packages -c -J generator/vendor generator/packages.libsonnet packages=$(wildcard packages/*) -output: packages $(packages) - rm -rf output && mkdir -p output/packages - $(foreach pkg,$(packages),$(CROSSPLANE) xpkg build --package-root=$(pkg) --package-file=output/$(pkg)-$(LIBRARY_VERSION)-$(PROVIDER_VERSION).xpkg;) +push_packages: packages $(packages) + rm -rf output && mkdir -p output/ + $(foreach pkg,$(packages),$(CROSSPLANE) xpkg build --package-root=$(pkg) --package-file=output/$(patsubst packages/%,%,$(pkg)).xpkg;) + $(foreach pkg,$(packages),echo $(CROSSPLANE) xpkg push configuration -f output/$(patsubst packages/%,%,$(pkg)).xpkg registry.upbound.io/grafana/$(patsubst packages/%,%,$(pkg)).xpkg:v$(LIBRARY_VERSION)-$(PROVIDER_VERSION);) docs: $(shell find grafanaplane/ -type f) @rm -rf docs/ @@ -43,3 +47,9 @@ docs: $(shell find grafanaplane/ -type f) .PHONY: tag tag: git tag $(LIBRARY_VERSION)-$(PROVIDER_VERSION) + +.PHONY: build +build: grafanaplane/raw.libsonnet grafanaplane/compositions.libsonnet packages + +.PHONY: push +push: push_packages