|
1 | | -name: build |
| 1 | +name: Candidate publication |
2 | 2 | on: |
3 | | - push: |
4 | | - branches: |
5 | | - - main |
6 | | - paths: |
7 | | - - app.py |
8 | | - - .github/** |
9 | | - - docs/** |
10 | | - - workflow.cwl.template |
11 | | - - requirements.txt |
12 | | - - Dockerfile |
13 | | - |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + publish_candidate: |
| 6 | + description: Publish candidate image after processing checks |
| 7 | + type: boolean |
| 8 | + default: false |
| 9 | +permissions: |
| 10 | + contents: read |
14 | 11 | jobs: |
15 | | - python-unit-test: |
16 | | - |
| 12 | + validate: |
| 13 | + uses: ./.github/workflows/acceptance.yml |
| 14 | + candidate: |
| 15 | + needs: validate |
17 | 16 | runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + packages: write |
18 | 20 | steps: |
19 | | - - uses: actions/checkout@v2 |
20 | | - - uses: actions/setup-python@v2 |
21 | | - with: |
22 | | - python-version: 3.x |
23 | | - - run: pip install -r requirements.txt |
24 | | - - run: pip install nose2 |
25 | | - - run: nose2 |
26 | | - |
27 | | - cwl-pack-validate: |
28 | | - needs: python-unit-test |
29 | | - runs-on: ubuntu-latest |
30 | | - steps: |
31 | | - - uses: actions/checkout@v2 |
32 | | - - uses: actions/setup-python@v2 |
33 | | - with: |
34 | | - python-version: 3.x |
35 | | - - run: pip install cwltool |
36 | | - - run: content=`cat app.py` yq eval '.$graph[1].requirements.InitialWorkDirRequirement.listing[0].entry=strenv(content)' workflow.cwl.template > workflow.cwl |
37 | | - - run: cwltool --validate workflow.cwl |
38 | | - |
39 | | - version: |
40 | | - needs: cwl-pack-validate |
41 | | - |
42 | | - runs-on: ubuntu-latest |
43 | | - |
44 | | - outputs: |
45 | | - |
46 | | - app-version: ${{ steps.set-version.outputs.version }} |
47 | | - |
48 | | - steps: |
49 | | - - uses: actions/checkout@v2 |
50 | | - - run: echo "APP_VERSION=$(cat codemeta.json | jq -r .version )" >> $GITHUB_ENV |
51 | | - - run: echo app version is $APP_VERSION |
52 | | - - id: set-version |
53 | | - run: echo "::set-output name=version::$APP_VERSION" |
54 | | - |
55 | | - container-build: |
56 | | - |
57 | | - needs: version |
58 | | - |
59 | | - runs-on: ubuntu-latest |
60 | | - |
61 | | - steps: |
62 | | - - uses: actions/checkout@v2 |
63 | | - - run: echo version ${{needs.version.outputs.app-version}} |
64 | | - - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin |
65 | | - - name: build & push image |
66 | | - run: | |
67 | | - IMAGE_ID=ghcr.io/eoap/quickwin-inline-code/python-inline-code |
68 | | - docker build . --file Dockerfile --tag $IMAGE_ID:${{needs.version.outputs.app-version}} |
69 | | - docker push $IMAGE_ID:${{needs.version.outputs.app-version}} |
70 | | -
|
71 | | - create-release: |
72 | | - |
73 | | - needs: |
74 | | - - container-build |
75 | | - - version |
76 | | - |
77 | | - runs-on: ubuntu-latest |
78 | | - |
79 | | - outputs: |
80 | | - |
81 | | - upload_url: ${{ steps.set-upload-url.outputs.upload_url }} |
82 | | - |
83 | | - steps: |
84 | | - - name: release |
85 | | - uses: actions/create-release@v1 |
86 | | - id: create_release |
87 | | - with: |
88 | | - draft: false |
89 | | - prerelease: false |
90 | | - release_name: ${{needs.version.outputs.app-version}} |
91 | | - tag_name: ${{needs.version.outputs.app-version}} |
92 | | - env: |
93 | | - GITHUB_TOKEN: ${{ github.token }} |
94 | | - - id: set-upload-url |
95 | | - run: echo "::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }}" |
96 | | - |
97 | | - publish-artifacts: |
98 | | - |
99 | | - needs: |
100 | | - - create-release |
101 | | - - version |
102 | | - |
103 | | - runs-on: ubuntu-latest |
104 | | - |
105 | | - steps: |
106 | | - - uses: actions/checkout@v2 |
107 | | - - run: content=`cat app.py` yq eval '.$graph[1].requirements.InitialWorkDirRequirement.listing[0].entry=strenv(content)' workflow.cwl.template > workflow.cwl |
108 | | - - run: | |
109 | | - tag="ghcr.io/eoap/quickwin-inline-code/python-inline-code:${{needs.version.outputs.app-version}}" |
110 | | - docker pull ${tag} |
111 | | - shatag=$( docker inspect ${tag} | yq -r '.[0]["RepoDigests"][0]' ) |
112 | | - s="detect-water-body" t="${shatag}" yq -i eval '(.$graph[] | select (.id == env(s)) ).hints.DockerRequirement.dockerPull = env(t)' workflow.cwl |
113 | | -
|
114 | | - - run: | |
115 | | - r=$( cat codemeta.json | jq -r ".codeRepository" ) yq -i eval '."s:codeRepository" = {"URL" : env(r)}' workflow.cwl |
116 | | - v="${{needs.version.outputs.app-version}}" yq -i eval '."s:softwareVersion" = env(v)' workflow.cwl |
117 | | - n=$(cat codemeta.json | jq -r '(.author[0].givenName + " " + .author[0].familyName)') \ |
118 | | - e=$(cat codemeta.json | jq -r '.author[0].email') \ |
119 | | - a=$(cat codemeta.json | jq -r '.author[0].affiliation["name"]') \ |
120 | | - yq eval -i '."s:author" += [{"class": "s:Person", "s.name": env(n), "s.email": env(e), "s.affiliation": env(a)}]' workflow.cwl |
121 | | - - run: | |
122 | | - mkdir downloads |
123 | | - cp workflow.cwl downloads/app-water-body-inline-code.${{needs.version.outputs.app-version}}.cwl |
124 | | - - uses: actions/upload-artifact@v4 |
125 | | - with: |
126 | | - name: application-package |
127 | | - path: downloads |
128 | | - - name: upload linux artifact 1 |
129 | | - uses: actions/upload-release-asset@v1 |
130 | | - env: |
131 | | - GITHUB_TOKEN: ${{ github.token }} |
132 | | - with: |
133 | | - upload_url: ${{needs.create-release.outputs.upload_url}} |
134 | | - asset_path: downloads/app-water-body-inline-code.${{needs.version.outputs.app-version}}.cwl |
135 | | - asset_name: app-water-body-inline-code.${{needs.version.outputs.app-version}}.cwl |
136 | | - asset_content_type: text/yaml |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + - uses: actions/setup-python@v5 |
| 23 | + with: |
| 24 | + python-version: '3.12' |
| 25 | + - uses: astral-sh/setup-uv@v6 |
| 26 | + - run: uv pip install --system --require-hashes -r requirements/development.txt |
| 27 | + - name: Build the intended runtime |
| 28 | + run: | |
| 29 | + docker build -t ghcr.io/eoap/quickwin-inline-code/python-inline-code:2.0.0-rc.${{ github.run_number }} . |
| 30 | + docker run --rm ghcr.io/eoap/quickwin-inline-code/python-inline-code:2.0.0-rc.${{ github.run_number }} python -m app --help |
| 31 | + - uses: docker/login-action@v3 |
| 32 | + if: inputs.publish_candidate |
| 33 | + with: |
| 34 | + registry: ghcr.io |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + - name: Publish candidate and prepare immutable CWL |
| 38 | + if: inputs.publish_candidate |
| 39 | + run: | |
| 40 | + image=ghcr.io/eoap/quickwin-inline-code/python-inline-code:2.0.0-rc.${{ github.run_number }} |
| 41 | + docker push "$image" |
| 42 | + published=$(docker inspect "$image" --format '{{index .RepoDigests 0}}') |
| 43 | + mkdir candidate |
| 44 | + python scripts/prepare-inline.py --image "$published" --version 2.0.0-rc.${{ github.run_number }} --output candidate/app-water-body-inline-code.cwl |
| 45 | + cwltool --validate candidate/app-water-body-inline-code.cwl |
| 46 | + cd candidate |
| 47 | + sha256sum app-water-body-inline-code.cwl > SHA256SUMS |
| 48 | + - uses: actions/upload-artifact@v4 |
| 49 | + if: inputs.publish_candidate |
| 50 | + with: |
| 51 | + name: inline-code-candidate |
| 52 | + path: candidate |
| 53 | +# Stable promotion requires recorded real-data and immutable-artifact acceptance, |
| 54 | +# resolved license metadata, and explicit release authorization. |
0 commit comments