Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit ecbf847

Browse files
committed
Add workflow for carver package and repo
- Copy relevant parts from POC to do dance with package and repo and use dockerhub for target location. - Relates #4528 - Relates #4529
1 parent 0ab7d0a commit ecbf847

File tree

15 files changed

+698
-1
lines changed

15 files changed

+698
-1
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build Package Bundle
2+
description: Build Package Bundle
3+
inputs:
4+
dataflow-version:
5+
description: dataflow version
6+
required: true
7+
skipper-version:
8+
description: skipper version
9+
required: true
10+
package-bundle-template:
11+
description: path to package bundle template
12+
required: true
13+
imgpkg-lock-template:
14+
description: path to imgpkg lock template
15+
required: true
16+
config:
17+
description: path to ytt config files dir
18+
required: true
19+
outputs:
20+
bundle-path:
21+
description: Location path where bundle was build
22+
value: ${{ steps.tanzu-dance.outputs.bundle-path }}
23+
24+
runs:
25+
using: "composite"
26+
steps:
27+
- uses: vmware-tanzu/carvel-setup-action@v1
28+
- name: Tanzu Dance
29+
id: tanzu-dance
30+
env:
31+
DATAFLOW_VERSION: ${{ inputs.dataflow-version }}
32+
SKIPPER_VERSION: ${{ inputs.skipper-version }}
33+
PACKAGE_BUNDLE_TEMPLATE: ${{ inputs.package-bundle-template }}
34+
PACKAGE_BUNDLE_GENERATED: ${{ runner.temp }}/generated/packagebundle
35+
VENDIR_SRC_IN: ${{ inputs.config }}
36+
IMGPKG_LOCK_TEMPLATE: ${{ inputs.imgpkg-lock-template }}
37+
IMGPKG_LOCK_GENERATED_IN: ${{ runner.temp }}/generated/imgpkgin
38+
IMGPKG_LOCK_GENERATED_OUT: ${{ runner.temp }}/generated/imgpkgout
39+
shell: bash
40+
run: |
41+
echo "::set-output name=bundle-path::$PACKAGE_BUNDLE_GENERATED"
42+
ytt \
43+
-f $PACKAGE_BUNDLE_TEMPLATE \
44+
--output-files $PACKAGE_BUNDLE_GENERATED \
45+
--data-value-yaml project.version=$DATAFLOW_VERSION \
46+
--data-value-yaml spring.cloud.skipper.version=$SKIPPER_VERSION \
47+
--file-mark 'config/values.yml:type=text-template'
48+
ytt \
49+
-f $IMGPKG_LOCK_TEMPLATE \
50+
--output-files $IMGPKG_LOCK_GENERATED_IN \
51+
--data-value-yaml project.version=$DATAFLOW_VERSION \
52+
--data-value-yaml spring.cloud.skipper.version=$SKIPPER_VERSION \
53+
--file-mark '**/*.yml:type=text-template'
54+
cp -R $VENDIR_SRC_IN $PACKAGE_BUNDLE_GENERATED/config/upstream
55+
vendir sync --chdir $PACKAGE_BUNDLE_GENERATED
56+
mkdir -p $IMGPKG_LOCK_GENERATED_OUT
57+
58+
for DIR in $(ls $IMGPKG_LOCK_GENERATED_IN)
59+
do
60+
ytt -f $PACKAGE_BUNDLE_GENERATED -f $IMGPKG_LOCK_GENERATED_IN/$DIR > $IMGPKG_LOCK_GENERATED_OUT/$DIR.yml
61+
done
62+
63+
mkdir -p $PACKAGE_BUNDLE_GENERATED/.imgpkg
64+
kbld \
65+
-f $IMGPKG_LOCK_GENERATED_OUT \
66+
--imgpkg-lock-output $PACKAGE_BUNDLE_GENERATED/.imgpkg/images.yml
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build Repository Bundle
2+
description: Build Repository Bundle
3+
inputs:
4+
version:
5+
description: dataflow version
6+
required: true
7+
repo-bundle-template:
8+
description: path to repo bundle template
9+
required: true
10+
package-bundle-repository:
11+
description: repository for package bundles
12+
required: true
13+
outputs:
14+
bundle-path:
15+
description: Location path where bundle was build
16+
value: ${{ steps.tanzu-dance.outputs.bundle-path }}
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- uses: vmware-tanzu/carvel-setup-action@v1
22+
- name: Tanzu Dance
23+
id: tanzu-dance
24+
env:
25+
VERSION: ${{ inputs.version }}
26+
PACKAGE_BUNDLE_REPOSITORY: ${{ inputs.package-bundle-repository }}
27+
REPO_BUNDLE_TEMPLATE: ${{ inputs.repo-bundle-template }}
28+
REPO_BUNDLE_RENDERED: ${{ runner.temp }}/generated/reporendered
29+
REPO_BUNDLE_GENERATED: ${{ runner.temp }}/generated/repobundle
30+
shell: bash
31+
run: |
32+
echo "::set-output name=bundle-path::$REPO_BUNDLE_GENERATED"
33+
34+
mkdir -p $REPO_BUNDLE_GENERATED/packages
35+
mkdir -p $REPO_BUNDLE_GENERATED/.imgpkg
36+
ytt \
37+
-f $REPO_BUNDLE_TEMPLATE \
38+
--output-files $REPO_BUNDLE_RENDERED \
39+
--data-value-yaml project.version=$VERSION \
40+
--data-value-yaml repository=$PACKAGE_BUNDLE_REPOSITORY \
41+
--file-mark 'package.yml:type=text-plain' \
42+
--file-mark 'metadata.yml:type=text-plain' \
43+
--file-mark 'values-schema.yml:type=text-plain' \
44+
--file-mark 'values-schema.star:type=text-plain' \
45+
--file-mark 'values-schema.star:for-output=true' \
46+
--file-mark 'versions.yml:type=text-template'
47+
48+
ytt \
49+
-f $REPO_BUNDLE_RENDERED \
50+
--file-mark 'values-schema.yml:type=data' \
51+
> $REPO_BUNDLE_GENERATED/packages/packages.yml
52+
53+
kbld \
54+
--file $REPO_BUNDLE_GENERATED/packages \
55+
--imgpkg-lock-output $REPO_BUNDLE_GENERATED/.imgpkg/images.yml
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish Bundle
2+
description: Publish Bundle
3+
inputs:
4+
path:
5+
description: path to bundle files
6+
required: true
7+
repository:
8+
description: repository to publish
9+
required: true
10+
version:
11+
description: semver version
12+
required: true
13+
prerelease:
14+
description: semver version prerelease
15+
required: false
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- uses: vmware-tanzu/carvel-setup-action@v1
21+
- name: Setup Envs
22+
shell: bash
23+
run: |
24+
echo RTAG=R$(date +%y%m%d%s%N) >> $GITHUB_ENV
25+
- name: Tanzu Dance
26+
id: tanzu-dance
27+
env:
28+
BUNDLE_PATH: ${{ inputs.path }}
29+
REPOSITORY: ${{ inputs.repository }}
30+
VERSION: ${{ inputs.version }}
31+
PRERELEASE: ${{ inputs.prerelease }}
32+
shell: bash
33+
run: |
34+
imgpkg push --bundle $REPOSITORY:$VERSION-RANDOM.$RTAG --file $BUNDLE_PATH
35+
docker pull $REPOSITORY:$VERSION-RANDOM.$RTAG
36+
37+
POSTFIX=$VERSION${PRERELEASE:+"-$PRERELEASE"}
38+
39+
docker tag $REPOSITORY:$VERSION-RANDOM.$RTAG $REPOSITORY:$POSTFIX
40+
docker push $REPOSITORY:$POSTFIX

.github/workflows/ci-carvel.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12+
13+
# test templating before publishing a package
1214
test:
13-
name: Run
15+
name: Test
1416
runs-on: ubuntu-latest
1517
defaults:
1618
run:
@@ -31,3 +33,67 @@ jobs:
3133
- name: Test
3234
run: |
3335
npm test
36+
37+
publish:
38+
name: Publish
39+
runs-on: ubuntu-latest
40+
needs: test
41+
steps:
42+
- uses: actions/checkout@v2
43+
- uses: jvalkeal/setup-maven@v1
44+
with:
45+
maven-version: 3.6.2
46+
- uses: jvalkeal/setup-maven@v1
47+
with:
48+
maven-version: 3.6.2
49+
- name: Login dockerhub
50+
uses: docker/login-action@v1
51+
with:
52+
username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
- name: Configure Env
55+
run: |
56+
echo spring_cloud_dataflow_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV
57+
echo spring_cloud_skipper_version=$(mvn help:evaluate -Dexpression=spring-cloud-skipper.version -q -DforceStdout) >> $GITHUB_ENV
58+
echo spring_cloud_dataflow_version_nopostfix=$(echo '${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}' | mvn build-helper:parse-version help:evaluate -q -DforceStdout) >> $GITHUB_ENV
59+
60+
# Builds a package bundle
61+
- name: Build Package Bundle
62+
id: build-package-bundle
63+
uses: ./.github/actions/build-package-bundle
64+
with:
65+
dataflow-version: ${{ env.spring_cloud_dataflow_version }}
66+
skipper-version: ${{ env.spring_cloud_skipper_version }}
67+
package-bundle-template: src/carvel/templates/bundle/package
68+
imgpkg-lock-template: src/carvel/templates/imgpkg
69+
config: src/carvel/config
70+
71+
# Publishes scdf package bundle as it needs to be in place
72+
# before repository bundle can be created.
73+
- name: Publish Package Bundle
74+
id: publish-package-bundle
75+
uses: ./.github/actions/publish-bundle
76+
with:
77+
path: ${{ steps.build-package-bundle.outputs.bundle-path }}
78+
repository: springcloud/scdf-package
79+
version: ${{ env.spring_cloud_dataflow_version_nopostfix }}
80+
prerelease: SNAPSHOT
81+
82+
# Builds a repository bundle
83+
- name: Build Repository Bundle
84+
id: build-repository-bundle
85+
uses: ./.github/actions/build-repository-bundle
86+
with:
87+
version: ${{ env.spring_cloud_dataflow_version }}
88+
repo-bundle-template: src/carvel/templates/bundle/repo
89+
package-bundle-repository: springcloud/scdf-package
90+
91+
# Publishes scdf repo bundle
92+
- name: Publish Repository Bundle
93+
id: publish-repository-bundle
94+
uses: ./.github/actions/publish-bundle
95+
with:
96+
path: ${{ steps.build-repository-bundle.outputs.bundle-path }}
97+
repository: springcloud/scdf-repo
98+
version: ${{ env.spring_cloud_dataflow_version_nopostfix }}
99+
prerelease: SNAPSHOT
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: imgpkg.carvel.dev/v1alpha1
2+
kind: Bundle
3+
metadata:
4+
name: scdf
5+
authors:
6+
- name: Janne Valkealahti
7+
email: janne.valkealahti@gmail.com
8+
websites:
9+
- url: https://spring.io/projects/spring-cloud-dataflow
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(@ load("@ytt:data", "data") @)#@data/values
2+
---
3+
scdf:
4+
deploy:
5+
binder:
6+
type: rabbit
7+
database:
8+
type: mysql
9+
server:
10+
image:
11+
tag: (@= data.values.project.version @)
12+
ctr:
13+
image:
14+
tag: (@= data.values.project.version @)
15+
skipper:
16+
image:
17+
tag: (@= data.values.spring.cloud.skipper.version @)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: vendir.k14s.io/v1alpha1
2+
kind: Config
3+
minimumRequiredVersion: 0.12.0
4+
directories:
5+
- path: config
6+
contents:
7+
- path: upstream
8+
manual: {}
9+
- path: values.yml
10+
manual: {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#@ load("@ytt:data", "data")
2+
apiVersion: data.packaging.carvel.dev/v1alpha1
3+
kind: PackageMetadata
4+
metadata:
5+
name: #@ data.values.package_repository.packageName
6+
namespace: scdf
7+
spec:
8+
displayName: "scdf"
9+
longDescription: "Spring Cloud Data Flow"
10+
shortDescription: "Spring Cloud Data Flow"
11+
providerName: VMware
12+
maintainers:
13+
- name: Janne Valkealahti
14+
categories:
15+
- "dataflow"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#@ load("@ytt:data", "data")
2+
#@ load("values-schema.star", "schema")
3+
4+
#@ def get_package_spec(package):
5+
#@ if hasattr(package, 'spec'):
6+
#@ return package.spec
7+
#@ end
8+
#@ return data.values.package_repository.packageSpec
9+
#@ end
10+
11+
#@ for/end package in data.values.package_repository.packages:
12+
---
13+
apiVersion: data.packaging.carvel.dev/v1alpha1
14+
kind: Package
15+
metadata:
16+
name: #@ str(package.name) + "." + str(package.domain) + "." + str(package.version)
17+
spec:
18+
refName: #@ package.name + "." + str(package.domain)
19+
publicName: #@ package.name + "." + str(package.domain)
20+
version: #@ package.version
21+
description: #@ package.description
22+
valuesSchema:
23+
openAPIv3: #@ schema()
24+
template:
25+
spec:
26+
syncPeriod: #@ get_package_spec(package).syncPeriod
27+
fetch:
28+
- imgpkgBundle:
29+
image: #@ package.image
30+
template:
31+
- ytt:
32+
ignoreUnknownComments: true
33+
paths:
34+
- config/
35+
- kbld:
36+
paths:
37+
- .imgpkg/images.yml
38+
- "-"
39+
deploy:
40+
- kapp:
41+
rawOptions: #@ ["--wait-timeout=" + str(get_package_spec(package).deploy.kappWaitTimeout)]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@ytt:data", "data")
2+
load("@ytt:yaml", "yaml")
3+
4+
def schema():
5+
content = yaml.decode(data.read("values-schema.yml"))
6+
return content.get("components").get("schemas").get("scdfPackage")
7+
end

0 commit comments

Comments
 (0)