@@ -2,142 +2,17 @@ name: build
22
33on :
44 push :
5- branches :
6- - develop
7- - main
8- paths :
9- - ' command-line-tools/**'
10- - .github/**
11- - docs/**
12- - cwl-workflow/*.cwl
13- - codemeta.json
5+ branches : [develop, main]
6+ tags :
7+ - ' v*'
148
159jobs :
16- validate :
17- runs-on : ubuntu-latest
18- steps :
19- - uses : actions/checkout@v2
20- - uses : actions/setup-python@v2
21- with :
22- python-version : 3.x
23- - run : pip install cwltool
24- - run : cwltool --validate cwl-workflow/app-water-bodies-cloud-native.cwl
25- - run : cwltool --validate cwl-workflow/app-water-body-cloud-native.cwl
26- - run : cwltool --validate cwl-workflow/app-water-body.cwl
27- - run : cwltool --validate cwl-workflow/app-water-bodies-cloud-native-geoparquet.cwl
28-
29- version :
30- needs : validate
31- runs-on : ubuntu-latest
32- outputs :
33- app-version : ${{ steps.set-version.outputs.version }}
34- steps :
35- - uses : actions/checkout@v2
36- - run : echo "APP_VERSION=$(jq -r .version codemeta.json)" >> $GITHUB_ENV
37- - run : echo app version is $APP_VERSION
38- - id : set-version
39- run : echo "::set-output name=version::$APP_VERSION"
40-
41- container-build :
42- needs : version
43- runs-on : ubuntu-latest
44- strategy :
45- matrix :
46- step : [crop, norm_diff, otsu, stac, stage, stac-geoparquet]
47- steps :
48- - uses : actions/checkout@v2
49- - run : echo version ${{ needs.version.outputs.app-version }}
50- - run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
51- - name : build & push image
52- run : |
53- IMAGE_ID=ghcr.io/eoap/advanced-tooling/${{ matrix.step }}
54- docker build command-line-tools/${{ matrix.step }} \
55- --file command-line-tools/${{ matrix.step }}/Dockerfile \
56- --tag ${{ matrix.step }}
57- docker tag ${{ matrix.step }} $IMAGE_ID:${{ needs.version.outputs.app-version }}
58- docker push $IMAGE_ID:${{ needs.version.outputs.app-version }}
59-
60- publish-oci-artifact :
61- needs :
62- - container-build
63- - version
64- runs-on : ubuntu-latest
65- steps :
66- - uses : actions/checkout@v2
67-
68- - name : Install oras and syft
69- run : |
70- ORAS_VERSION="1.2.2"
71- curl -sL "https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz" | tar -xz oras
72- sudo mv oras /usr/local/bin/
73- SYFT_VERSION="1.27.1"
74- curl -sL "https://github.com/anchore/syft/releases/download/v${SYFT_VERSION}/syft_${SYFT_VERSION}_linux_amd64.tar.gz" | tar -xz syft
75- sudo mv syft /usr/local/bin/
76-
77- - name : Authenticate with GitHub Container Registry
78- run : echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
79-
80- - name : Prepare CWL files and metadata
81- run : |
82- VERSION="${{ needs.version.outputs.app-version }}"
83- mkdir -p downloads sboms
84-
85- for step in crop norm_diff otsu stac stac-geoparquet
86- do
87- tag="ghcr.io/eoap/advanced-tooling/${step}:${VERSION}"
88- docker pull "$tag"
89- digest=$(docker inspect "$tag" | yq -r '.[0]["RepoDigests"][0]')
90- for cwl in cwl-workflow/*.cwl
91- do
92- s="${step}" t="${digest}" yq -i eval '(.$graph[] | select (.id == env(s)) ).hints.DockerRequirement.dockerPull = env(t)' "$cwl"
93- done
94- done
95-
96- for cwl in $(ls cwl-workflow/*.cwl)
97- do
98- r=$( cat codemeta.json | jq -r ".codeRepository" ) yq -i eval '."s:codeRepository" = {"URL" : env(r)}' $cwl
99- v="${{needs.version.outputs.app-version}}" yq -i eval '."s:softwareVersion" = env(v)' $cwl
100- n=$(cat codemeta.json | jq -r '(.author[0].givenName + " " + .author[0].familyName)') \
101- e=$(cat codemeta.json | jq -r '.author[0].email') \
102- a=$(cat codemeta.json | jq -r '.author[0].affiliation["name"]') \
103- yq eval -i '."s:author" += [{"class": "s:Person", "s.name": env(n), "s.email": env(e), "s.affiliation": env(a)}]' $cwl
104- done
105-
106- for cwl in cwl-workflow/*.cwl
107- do
108- base=$(basename "$cwl" .cwl)
109- cp "$cwl" "downloads/${base}.${VERSION}.cwl"
110- done
111-
112- - name : Push OCI artifacts and attach SBOMs
113- run : |
114- VERSION="${{ needs.version.outputs.app-version }}"
115- OWNER_REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
116- set -x
117- for file in downloads/*.cwl
118- do
119- base=$(basename "$file" .${VERSION}.cwl)
120- ref="ghcr.io/${OWNER_REPO}/${base}:${VERSION}"
121-
122- echo "Pushing $file as OCI artifact to $ref"
123- oras push "$ref" --artifact-type application/cwl "$file":application/cwl
124-
125- echo "Extracting image references from $file"
126- images=$(yq e '
127- .["$graph"][]
128- | select(.class == "CommandLineTool")
129- | (.hints.DockerRequirement.dockerPull // .requirements.DockerRequirement.dockerPull)
130- ' "$file")
131-
132- for image in $images
133- do
134- safe_name=$(echo "$image" | tr '/@:' '___')
135- sbom_file="sboms/$safe_name.sbom.spdx.json"
136-
137- echo "Generating SBOM for $image"
138- syft "$image" -o spdx-json > "$sbom_file"
139-
140- echo "Attaching SBOM for $image to $ref"
141- oras attach "$ref" --artifact-type application/spdx+json "$sbom_file"
142- done
143- done
10+ release :
11+ uses : eoap/eoap-cwl-release-workflow/.github/workflows/release-cwl.yml@main
12+ with :
13+ tools : ' ["crop","norm_diff","otsu","stac","stage","stac-geoparquet"]'
14+ image-prefix : ghcr.io/eoap/advanced-tooling
15+ cwl-dir : cwl-workflow
16+ secrets :
17+ registry-user : ${{ github.actor }}
18+ registry-password : ${{ secrets.GITHUB_TOKEN }}
0 commit comments