|
| 1 | +name: Build-install-zip-file (on release) |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + id-token: write |
| 10 | + attestations: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: [self-hosted, Windows, Office] |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: "Checkout code for release tag" |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + ref: ${{ github.event.release.tag_name }} |
| 21 | + |
| 22 | + - name: "Build add-in" |
| 23 | + id: build_add_in |
| 24 | + uses: AccessCodeLib/msaccess-vcs-build@main |
| 25 | + with: |
| 26 | + source-dir: "source" |
| 27 | + target-dir: "bin" |
| 28 | + file-name: "ACLibDeclarationDictCore.accda" |
| 29 | + run-accunit-tests: true |
| 30 | + timeout-minutes: 10 |
| 31 | + |
| 32 | + - name: "Build DeclDictTester" |
| 33 | + id: build_delc_dict_tester |
| 34 | + uses: AccessCodeLib/msaccess-vcs-build@main |
| 35 | + with: |
| 36 | + source-dir: "DeclDictTester.accdb.src" |
| 37 | + target-dir: "bin" |
| 38 | + file-name: "DeclDictTester.accdb" |
| 39 | + run-accunit-tests: true |
| 40 | + timeout-minutes: 10 |
| 41 | + |
| 42 | + - name: "Build Example_APIusage" |
| 43 | + id: build_example_api_usage |
| 44 | + uses: AccessCodeLib/msaccess-vcs-build@main |
| 45 | + with: |
| 46 | + source-dir: "Example_APIusage.accdb.src" |
| 47 | + target-dir: "bin" |
| 48 | + file-name: "Example_APIusage.accdb" |
| 49 | + timeout-minutes: 10 |
| 50 | + |
| 51 | + - name: "Create versioned ZIP file" |
| 52 | + run: | |
| 53 | + $zipName = "ACLibImportWizard_${{ github.event.release.tag_name }}.zip" |
| 54 | + Compress-Archive -Path .\bin\*.accda, .\bin\Example_APIusage.accdb -DestinationPath $zipName |
| 55 | + echo "ZIP_NAME=$zipName" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 56 | +
|
| 57 | + - name: "Upload ZIP to GitHub Release" |
| 58 | + uses: softprops/action-gh-release@v1 |
| 59 | + with: |
| 60 | + files: ${{ env.ZIP_NAME }} |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - name: "Calculate SHA256 of ZIP" |
| 65 | + id: hash |
| 66 | + shell: pwsh |
| 67 | + run: | |
| 68 | + $zipName = "${{ env.ZIP_NAME }}" |
| 69 | + $hash = Get-FileHash -Algorithm SHA256 -Path $zipName |
| 70 | + $digest = "sha256:$($hash.Hash.ToLower())" |
| 71 | + echo "ZIP_DIGEST=$digest" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 72 | + echo "digest=$digest" >> $env:GITHUB_OUTPUT |
| 73 | +
|
| 74 | + - name: "Attestation" |
| 75 | + uses: actions/attest-build-provenance@v2 |
| 76 | + id: attestation |
| 77 | + with: |
| 78 | + subject-name: "${{ env.ZIP_NAME }}" |
| 79 | + subject-digest: "${{ steps.hash.outputs.digest }}" |
| 80 | + |
| 81 | + - name: "Update release description with attestation URL" |
| 82 | + shell: pwsh |
| 83 | + env: |
| 84 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + REPO: ${{ github.repository }} |
| 86 | + TAG: ${{ github.event.release.tag_name }} |
| 87 | + run: | |
| 88 | + $ErrorActionPreference = "Stop" |
| 89 | +
|
| 90 | + # get current release notes |
| 91 | + $oldBody = gh release view $env:TAG --repo $env:REPO --json body --template "{{.body}}" |
| 92 | +
|
| 93 | + # build Attestation URL |
| 94 | + $attestationId = "${{ steps.attestation.outputs.attestation-id }}" |
| 95 | + $attestationUrl = "https://github.com/$($env:REPO)/attestations/$attestationId" |
| 96 | +
|
| 97 | + # join release notes with Attestation url |
| 98 | + $newBody = "$oldBody`n`nAttestation: $attestationUrl" |
| 99 | +
|
| 100 | + # save release notes |
| 101 | + gh release edit $env:TAG --repo $env:REPO --notes "$newBody" |
| 102 | +
|
| 103 | + |
0 commit comments