build-pre-release #175
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Daily build and release workflow. | |
| name: build-pre-release | |
| on: | |
| # Runs daily at UTC midnight to minimize risk of overstepping | |
| # manual builds of same date. | |
| schedule: | |
| - cron: "0 0 * * *" | |
| # Allow manual activations. | |
| workflow_dispatch: | |
| permissions: | |
| # Allow release creation | |
| contents: write | |
| env: | |
| # -- Set the version of the upstream release. | |
| # -- See list at https://graphviz.gitlab.io/download/ | |
| GRAPHVIZ_TAG: 12.1.2 | |
| # -- These are set latter. | |
| RELEASE_TAG: "" | |
| PACKAGE_TAG: "" | |
| jobs: | |
| # -- Build packages for all supported architectures and | |
| # -- export them in a release. | |
| build-pre-release: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| # Check out the this repo in the workflow work directory. | |
| - name: Checkout this repo | |
| uses: actions/checkout@v4 | |
| - name: Get release and package tags | |
| uses: fpgawars/apio-workflows/.github/actions/get-release-and-package-tags@main | |
| with: | |
| release-tag-var: RELEASE_TAG | |
| package-tag-var: PACKAGE_TAG | |
| # - name: Get repository commit | |
| # uses: fpgawars/apio-workflows/.github/actions/get-repo-commit@main | |
| # with: | |
| # repo-dir: . | |
| # env-var-name: RELEASE_COMMIT | |
| - name: Get repository commit | |
| uses: fpgawars/apio-workflows/.github/actions/get-repo-info@main | |
| with: | |
| repo-dir: . | |
| commit-var: RELEASE_COMMIT | |
| - name: Determine package file name | |
| run: | | |
| package_name="apio-graphviz-windows-amd64-${PACKAGE_TAG}.tgz" | |
| echo "PACKAGE_NAME=$package_name" | |
| echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV | |
| - name: Create the build info file | |
| run: | | |
| cat > build-info.json <<EOF | |
| { | |
| "package-name": "graphviz", | |
| "description" : "Graphviz tools for Apio", | |
| "target-platform": "windows-amd64", | |
| "release-tag": "${RELEASE_TAG}", | |
| "build-repo": "${{github.repository}}", | |
| "build-workflow": "${{ github.workflow }}", | |
| "workflow-run-id": "${{github.run_id}}", | |
| "workflow-run-number": "${{github.run_number}}", | |
| "build-time": "$(date +'%Y-%m-%d %H:%M:%S %Z')", | |
| "commit": "$RELEASE_COMMIT", | |
| "file-name": "$PACKAGE_NAME" | |
| } | |
| EOF | |
| cat -n build-info.json | |
| - name: Format build info json file in-place | |
| uses: fpgawars/apio-workflows/.github/actions/format-json-file@main | |
| with: | |
| json-file: build-info.json | |
| - name: Construct graphviz file name | |
| run: | | |
| graphviz_fname="windows_10_cmake_Release_Graphviz-${GRAPHVIZ_TAG}-win64.zip" | |
| echo "GRAPHVIZ_FNAME=${graphviz_fname}" | |
| echo "GRAPHVIZ_FNAME=${graphviz_fname}" >> $GITHUB_ENV | |
| - name: Download graphviz file to _upstream | |
| run: | | |
| url="https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/${GRAPHVIZ_TAG}/${GRAPHVIZ_FNAME}" | |
| echo $url | |
| mkdir _upstream | |
| pushd _upstream | |
| wget -nv $url | |
| popd | |
| find _upstream | |
| - name: Uncompress the graphviz file | |
| run: | | |
| pushd _upstream | |
| unzip ${GRAPHVIZ_FNAME} | |
| popd | |
| find _upstream | |
| - name: Move upstream package to _package | |
| run: | | |
| mv _upstream/Graphviz-${GRAPHVIZ_TAG}-win64 _package | |
| ls -al _package | |
| - name: Copy build info file to _package | |
| run: | | |
| cp build-info.json _package/BUILD-INFO.json | |
| ls -al _package | |
| - name: Compress the package | |
| run: | | |
| pushd _package | |
| tar zcf ../${PACKAGE_NAME} ./* | |
| popd | |
| ls -al | |
| - name: Scan the package for viruses | |
| uses: fpgawars/apio-workflows/.github/actions/scan-files-for-viruses@main | |
| with: | |
| file-patterns: | | |
| apio-graphviz-*.tgz | |
| - name: Convert json build info to text | |
| uses: fpgawars/apio-workflows/.github/actions/json-to-text@main | |
| with: | |
| input-json: build-info.json | |
| output-text: build-info.txt | |
| # Summary for the workflow run page. | |
| - name: Prepare workflow run summary | |
| run: | | |
| cat > RUN-SUMMARY.txt <<EOF | |
| Build info: | |
| \`\`\` | |
| $(cat build-info.txt) | |
| \`\`\` | |
| - [Cutoff commit](https://github.com/${{ github.repository }}/commit/${RELEASE_COMMIT}) | |
| - [Generated pre-release](https://github.com/${{ github.repository }}/releases/tag/${RELEASE_TAG}) | |
| EOF | |
| ls -al | |
| cat -n RUN-SUMMARY.txt | |
| - name: Post workflow run summary | |
| run: | | |
| cat RUN-SUMMARY.txt >> $GITHUB_STEP_SUMMARY | |
| - name: Prepare release text | |
| run: | | |
| cat > RELEASE-BODY.txt <<EOF | |
| > ### Pre-release note | |
| > | |
| > This daily release was created as a pre-release and | |
| > will be deleted after 5 days unless if it's marked as a stable release. To make | |
| > this a stable release, do the following: | |
| > * Open the release for editing. | |
| > * Turn off the \`Set as a pre-release\` checkbox below. | |
| > * (optional) Turn on the \`Set as the latest release\` checkbox. | |
| > * Remove this pre-release note. | |
| > * (optional) Add release notes. | |
| > * Click \`Update Release\` button to save your changes. | |
| ### Build info | |
| \`\`\` | |
| $(cat build-info.txt) | |
| \`\`\` | |
| EOF | |
| cat -n RELEASE-BODY.txt | |
| - name: Cleanup old pre-releases | |
| uses: fpgawars/apio-workflows/.github/actions/cleanup-old-prereleases@main | |
| - name: Ensure no conflicting release | |
| uses: fpgawars/apio-workflows/.github/actions/ensure-no-conflicting-release@main | |
| with: | |
| release-tag: ${{ env.RELEASE_TAG }} | |
| - name: Create GitHub pre-release | |
| uses: fpgawars/apio-workflows/.github/actions/create-pre-release@main | |
| with: | |
| release_tag: ${{ env.RELEASE_TAG }} | |
| body_path: RELEASE-BODY.txt | |
| # We intensionally list explicitly all the expected files. | |
| files: | | |
| apio-graphviz-windows-amd64-${{env.PACKAGE_TAG}}.tgz |