Skip to content

Commit

Permalink
feat: push packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic committed Dec 2, 2024
1 parent c91d16d commit 53c81a0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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/
Expand All @@ -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

0 comments on commit 53c81a0

Please sign in to comment.