Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate all component builds: ca => ctf #1043

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 0 additions & 67 deletions .github/workflows/buildcomponents.yaml

This file was deleted.

45 changes: 5 additions & 40 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,17 @@ jobs:
with:
fetch-depth: 0

- name: Job Settings
run: |
echo "Release Job Arguments"
if ${{ github.event.inputs.release_candidate }}; then
v="v$(go run $GITHUB_WORKSPACE/api/version/generate --no-dev print-rc-version ${{ github.event.inputs.prerelease }})"
if [ -n "${{ github.event.inputs.prerelease }}" ]; then
echo "Candidate: $v"
else
echo "Candidate: $v (taken from source)"
fi
else
v="v$(go run $GITHUB_WORKSPACE/api/version/generate print-version)"
echo "Final Release: $v"
if ${{ github.event.inputs.create_branch }}; then
echo "with release branch creation"
else
echo "without release branch creation"
fi
fi

- name: Set Base Version
- name: Generate Base Version
run: |
BASE_VERSION=v$(go run $GITHUB_WORKSPACE/api/version/generate print-version)
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV

- name: Set Pre-Release Version
- name: Generate Pre-Release Version
if: inputs.release_candidate == true
run: |
RELEASE_VERSION=v$(go run $GITHUB_WORKSPACE/api/version/generate --no-dev print-rc-version ${{ github.event.inputs.prerelease }})
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV

- name: Set Version
- name: Generate Release Version
if: inputs.release_candidate == false
run: |
RELEASE_VERSION=${{env.BASE_VERSION}}
Expand Down Expand Up @@ -96,27 +75,14 @@ jobs:
draft: true
releaseName: ${{ env.BASE_VERSION }}

lint-and-test:
name: Lint and Unit Tests
uses: ./.github/workflows/lint_and_test.yaml
needs: check
permissions:
contents: read
pull-requests: read
components:
name: Component CTF Builds
uses: ./.github/workflows/components.yaml
needs: check
permissions:
contents: read
pull-requests: read
diff-check-manifests:
name: Check for diff after go mod tidy and generated targets
uses: ./.github/workflows/check_diff_action.yaml
needs: check
permissions:
contents: read
pull-requests: read


release:
needs:
Expand All @@ -141,6 +107,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
# fetch all history so we can calculate the version and tagging
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}

Expand Down Expand Up @@ -188,14 +155,12 @@ jobs:
run: |
BASE_VERSION=v$(go run $GITHUB_WORKSPACE/api/version/generate print-version)
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV

- name: Set Pre-Release Version
if: inputs.release_candidate == true
run: |
RELEASE_VERSION=v$(go run $GITHUB_WORKSPACE/api/version/generate --no-dev print-rc-version ${{ github.event.inputs.prerelease }})
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "release name is $RELEASE_VERSION"

- name: Set Version
if: inputs.release_candidate == false
run: |
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PLATFORMS = windows/amd64 darwin/arm64 darwin/amd64 linux/amd64 linux/arm64

CREDS ?=
OCM := go run $(REPO_ROOT)/cmds/ocm $(CREDS)
CTF_TYPE ?= tgz
CTF_TYPE ?= directory

GEN := $(REPO_ROOT)/gen

Expand All @@ -37,25 +37,25 @@ build: bin bin/ocm bin/helminstaller bin/demo bin/cliplugin bin/ecrplugin
bin:
mkdir -p bin

bin/ocm: bin ${SOURCES}
bin/ocm: bin $(SOURCES)
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/ocm ./cmds/ocm

bin/helminstaller: bin ${SOURCES}
bin/helminstaller: bin $(SOURCES)
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/helminstaller ./cmds/helminstaller

bin/demo: bin ${SOURCES}
bin/demo: bin $(SOURCES)
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/demo ./cmds/demoplugin

bin/cliplugin: bin ${SOURCES}
bin/cliplugin: bin $(SOURCES)
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/cliplugin ./cmds/cliplugin

bin/ecrplugin: bin ${SOURCES}
bin/ecrplugin: bin $(SOURCES)
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/ecrplugin ./cmds/ecrplugin

api: ${SOURCES}
api: $(SOURCES)
go build ./api/...

examples: ${SOURCES}
examples: $(SOURCES)
go build ./examples/...


Expand Down
41 changes: 24 additions & 17 deletions components/demoplugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GITHUBORG ?= open-component-model
COMPONENT = $(PROVIDER)/plugins/$(NAME)
OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm
PLATFORMS = linux/amd64 linux/arm64
CTF_TYPE ?= directory

REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../..
VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE))
Expand All @@ -12,7 +13,7 @@ EFFECTIVE_VERSION = $(VERSION)+$(COMMIT)
GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty)

CMDSRCS=$(shell find $(REPO_ROOT)/cmds/$(NAME) -type f)
OCMSRCS=$(shell find $(REPO_ROOT)/pkg -type f) $(REPO_ROOT)/go.*
OCMSRCS=$(shell find $(REPO_ROOT)/api -type f) $(REPO_ROOT)/go.*

CREDS ?=
# Define the path to the binary
Expand All @@ -28,18 +29,20 @@ OCM = $(OCM_BIN) $(CREDS)

GEN = $(REPO_ROOT)/gen/$(NAME)

$(GEN):
@mkdir -p $(GEN)

NOW := $(shell date -u +%FT%T%z)
BUILD_FLAGS := "-s -w \
-X ocm.software/ocm/api/version.gitVersion=$(EFFECTIVE_VERSION) \
-X ocm.software/ocm/api/version.gitTreeState=$(GIT_TREE_STATE) \
-X ocm.software/ocm/api/version.gitCommit=$(COMMIT) \
-X ocm.software/ocm/api/version.buildDate=$(NOW)"


.PHONY: build
build: $(GEN)/build

$(GEN)/build: $(CMDSRCS) $(OCMSRCS)
$(GEN)/build: $(GEN) $(CMDSRCS) $(OCMSRCS)
@for i in $(PLATFORMS); do \
tag=$$(echo $$i | sed -e s:/:-:g); \
echo GOARCH=$$(basename $$i) GOOS=$$(dirname $$i) CGO_ENABLED=0 go build -ldflags $(BUILD_FLAGS) -o $(GEN)/$(NAME).$$tag ../../cmds/$(NAME); \
Expand All @@ -51,23 +54,27 @@ $(GEN)/build: $(CMDSRCS) $(OCMSRCS)
.PHONY: ctf
ctf: $(GEN)/ctf

$(GEN)/ctf: $(GEN)/ca.done $(OCM_BIN)
$(GEN)/ctf: $(OCM_BIN) $(GEN)/.exists $(GEN)/build component-constructor.yaml $(CHARTSRCS)
@rm -rf "$(GEN)/ctf"
$(OCM) transfer ca $(GEN)/ca $(GEN)/ctf
$(OCM) add componentversions \
--create \
--file $(GEN)/ctf \
--type $(CTF_TYPE) \
--templater=spiff \
COMPONENT="$(COMPONENT)" \
NAME="$(NAME)" \
VERSION="$(VERSION)" \
PROVIDER="$(PROVIDER)" \
COMMIT="$(COMMIT)" \
GEN="$(GEN)" \
PLATFORMS="$(PLATFORMS)" \
component-constructor.yaml
touch "$(GEN)/ctf"

.PHONY: version
version:
@echo $(VERSION)

.PHONY: ca
ca: $(GEN)/ca.done

$(GEN)/ca.done: $(GEN)/.exists $(GEN)/build resources.yaml $(CHARTSRCS) $(OCM_BIN)
$(OCM) create ca -f $(COMPONENT) "$(VERSION)" --provider $(PROVIDER) --file $(GEN)/ca
$(OCM) add resources --templater=spiff --file $(GEN)/ca NAME="$(NAME)" VERSION="$(VERSION)" COMMIT="$(COMMIT)" GEN="$(GEN)" PLATFORMS="$(PLATFORMS)" resources.yaml
@touch $(GEN)/ca.done

.PHONY: push
push: $(GEN)/ctf $(GEN)/push.$(NAME)

Expand Down Expand Up @@ -97,12 +104,12 @@ info:
@echo "COMMIT; $(COMMIT)"

.PHONY: describe
describe: $(GEN)/ctf
ocm get resources --lookup $(OCMREPO) -c -o treewide $(GEN)/ctf
describe: $(GEN)/ctf $(OCM_BIN)
$(OCM) get resources --lookup $(OCMREPO) -c -o treewide $(GEN)/ctf

.PHONY: descriptor
descriptor: $(GEN)/ctf
ocm get component -S v3alpha1 -o yaml $(GEN)/ctf
descriptor: $(GEN)/ctf $(OCM_BIN)
$(OCM) get component -S v3alpha1 -o yaml $(GEN)/ctf

.PHONY: clean
clean:
Expand Down
23 changes: 23 additions & 0 deletions components/demoplugin/component-constructor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
helper:
<<<: (( &temporary ))
executable:
<<<: (( &template ))
name: demo
type: ocmPlugin
version: (( values.VERSION ))
extraIdentity:
os: ((dirname(p) ))
architecture: (( basename(p) ))
input:
type: file
# Generate the path to the plugin binary by looking into the base path and encoding the platform
path: (( values.GEN "/" values.NAME "." replace(p,"/","-") ))

components:
- name: (( values.COMPONENT))
version: (( values.VERSION))
provider:
name: (( values.PROVIDER))
# use all platforms and create a resource for each
resources: (( map[split(" ", values.PLATFORMS)|p|-> *helper.executable] ))
18 changes: 0 additions & 18 deletions components/demoplugin/resources.yaml

This file was deleted.

Loading