|
34 | 34 | description: The root SBD that is being used as the modulefile name
|
35 | 35 | env:
|
36 | 36 | SPACK_YAML_MODULEFILE_PROJECTION_YQ: .spack.modules.default.tcl.projections.${{ inputs.root-sbd }}
|
| 37 | + METADATA_PATH: /opt/metadata |
37 | 38 | jobs:
|
38 | 39 | deploy-to-environment:
|
39 | 40 | name: Deploy to ${{ inputs.deployment-environment }}
|
40 | 41 | runs-on: ubuntu-latest
|
41 | 42 | environment: ${{ inputs.deployment-environment }}
|
| 43 | + outputs: |
| 44 | + packages-version: ${{ steps.versions.outputs.packages }} |
| 45 | + config-version: ${{ steps.versions.outputs.config }} |
42 | 46 | steps:
|
43 | 47 | # Deployment
|
44 | 48 | - uses: actions/checkout@v4
|
@@ -95,32 +99,99 @@ jobs:
|
95 | 99 |
|
96 | 100 | # Obtain metadata
|
97 | 101 | spack find --paths > ${{ vars.SPACK_LOCATION }}/var/spack/environments/${{ inputs.env-name }}/spack.location
|
98 |
| - spack find --format '{name}@{version} {prefix}' | jq --raw-input --null-input '[inputs | split(" ") | {(.[0]):(.[1])}] | add' > ${{ vars.SPACK_LOCATION }}/var/spack/environments/${{ inputs.env-name }}/spack.location.json |
| 102 | + spack find --format '{hash} {prefix}' | jq --raw-input --null-input '[inputs | split(" ") | {(.[0]): (.[1])}] | add' > ${{ vars.SPACK_LOCATION }}/var/spack/environments/${{ inputs.env-name }}/spack.location.json |
99 | 103 |
|
100 | 104 | spack env deactivate
|
101 | 105 | echo "$(date): Deployed ${{ inputs.model }} ${{ inputs.version }} with spack-packages ${{ steps.versions.outputs.packages }}, spack-config ${{ steps.versions.outputs.config }}" >> ${{ vars.SPACK_RELEASE_LOCATION }}/release.log
|
102 | 106 | EOT
|
103 | 107 |
|
104 | 108 | # Release
|
105 | 109 | - name: Get Release Metadata
|
106 |
| - if: inputs.type == 'release' |
107 | 110 | run: |
|
108 | 111 | rsync -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \
|
109 | 112 | '${{ secrets.USER}}@${{ secrets.HOST_DATA }}:${{ vars.SPACK_LOCATION }}/var/spack/environments/${{ inputs.env-name }}/spack.*' \
|
110 | 113 | ./${{ inputs.env-name }}
|
111 | 114 |
|
| 115 | + - name: Upload Metadata Artifact |
| 116 | + uses: actions/upload-artifact@v4 |
| 117 | + with: |
| 118 | + name: ${{ inputs.env-name }} |
| 119 | + path: ./${{ inputs.env-name }}/* |
| 120 | + overwrite: true |
| 121 | + |
| 122 | + release: |
| 123 | + name: Create Release |
| 124 | + if: inputs.type == 'release' |
| 125 | + needs: |
| 126 | + - deploy-to-environment |
| 127 | + runs-on: ubuntu-latest |
| 128 | + outputs: |
| 129 | + url: ${{ steps.release.outputs.url }} |
| 130 | + created-at: ${{ steps.metadata.outputs.created-at }} |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v4 |
| 133 | + |
| 134 | + - name: Download Metadata Artifact |
| 135 | + uses: actions/download-artifact@v4 |
| 136 | + with: |
| 137 | + name: ${{ inputs.env-name }} |
| 138 | + path: ${{ env.METADATA_PATH }} |
| 139 | + |
112 | 140 | - name: Create Release
|
113 |
| - if: inputs.type == 'release' |
114 |
| - uses: softprops/action-gh-release@v0.1.15 |
| 141 | + id: release |
| 142 | + uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 # v2.0.5 |
115 | 143 | with:
|
116 | 144 | tag_name: ${{ inputs.version }}
|
117 | 145 | name: ${{ inputs.model}} ${{ inputs.version }}
|
118 | 146 | body: |
|
119 |
| - This release of ${{ inputs.model }} ${{ inputs.version }} uses [spack-packages ${{ steps.versions.outputs.packages }}](https://github.com/ACCESS-NRI/spack-packages/releases/tag/${{ steps.versions.outputs.packages }}) and [spack-config ${{ steps.versions.outputs.config }}](https://github.com/ACCESS-NRI/spack-config/releases/tag/${{ steps.versions.outputs.config }}). |
| 147 | + This release of ${{ inputs.model }} ${{ inputs.version }} uses [spack-packages ${{ needs.deploy-to-environment.outputs.packages-version }}](https://github.com/ACCESS-NRI/spack-packages/releases/tag/${{ needs.deploy-to-environment.outputs.packages-version }}) and [spack-config ${{ needs.deploy-to-environment.outputs.config-version }}](https://github.com/ACCESS-NRI/spack-config/releases/tag/${{ needs.deploy-to-environment.outputs.config-version }}). |
120 | 148 | generate_release_notes: true
|
121 | 149 | fail_on_unmatched_files: true
|
122 | 150 | files: |
|
123 |
| - ./${{ inputs.env-name }}/spack.yaml |
124 |
| - ./${{ inputs.env-name }}/spack.lock |
125 |
| - ./${{ inputs.env-name }}/spack.location |
126 |
| - ./${{ inputs.env-name }}/spack.location.json |
| 151 | + ./${{ env.METADATA_PATH }}/spack.yaml |
| 152 | + ./${{ env.METADATA_PATH }}/spack.lock |
| 153 | + ./${{ env.METADATA_PATH }}/spack.location |
| 154 | + ./${{ env.METADATA_PATH }}/spack.location.json |
| 155 | +
|
| 156 | + - name: Release Metadata |
| 157 | + id: metadata |
| 158 | + env: |
| 159 | + GH_TOKEN: ${{ github.token }} |
| 160 | + run: echo "created-at=$(gh release view --json createdAt --jq '.createdAt')" >> $GITHUB_OUTPUT |
| 161 | + |
| 162 | + build-db: |
| 163 | + name: Build DB Metadata Upload |
| 164 | + if: inputs.type == 'release' |
| 165 | + needs: |
| 166 | + - release |
| 167 | + runs-on: ubuntu-latest |
| 168 | + steps: |
| 169 | + - name: Download Metadata Artifact |
| 170 | + uses: actions/download-artifact@v4 |
| 171 | + with: |
| 172 | + name: ${{ inputs.env-name }} |
| 173 | + path: ${{ env.METADATA_PATH }} |
| 174 | + |
| 175 | + - name: Checkout Upload Script |
| 176 | + uses: actions/checkout@v4 |
| 177 | + with: |
| 178 | + repository: access-nri/build-cd |
| 179 | + |
| 180 | + - name: Setup Python |
| 181 | + uses: actions/setup-python@v5 |
| 182 | + with: |
| 183 | + python-version: "3.10" |
| 184 | + cache: pip |
| 185 | + |
| 186 | + - name: Install Build Metadata Script Requirements |
| 187 | + run: pip install -r tools/release_provenance/requirements.txt |
| 188 | + |
| 189 | + - name: Upload Build Metadata |
| 190 | + env: |
| 191 | + BUILD_DB_CONNECTION_STR: ${{ secrets.BUILD_DB_CONNECTION_STR }} |
| 192 | + OUTPUT_PATH: ./metadata_output |
| 193 | + run: | |
| 194 | + ./scripts/generate-build-metadata.bash ${{ needs.release.outputs.url }} ${{ needs.release.outputs.created-at }} ${{ env.METADATA_PATH }} ${{ env.OUTPUT_PATH }} ${{ inputs.root-sbd }} ${{ vars.BUILD_DB_PACKAGES }} |
| 195 | +
|
| 196 | + echo "Attempting upload of build_metadata.json" |
| 197 | + python ./tools/release_provenance/save_release.py "${{ env.OUTPUT_PATH }}/build_metadata.json" |
0 commit comments