build-pre-release #43
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
| 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: | |
| # The Python version of the pyinstaller binaries. | |
| PYTHON_VERSION: "3.14" | |
| # Apio repo branch to use. | |
| APIO_TARGET_BRANCH: ${{github.event.inputs.apio_branch || 'main'}} | |
| # These are set later. | |
| RELEASE_TAG: "" | |
| PACKAGE_TAG: "" | |
| APIO_COMMIT: "" | |
| APIO_VERSION: "" | |
| BUILDER_BRANCH: "" | |
| BUILDER_COMMIT: "" | |
| jobs: | |
| # ----- Parameters collection job | |
| prepare: | |
| runs-on: ubuntu-latest | |
| # outputs: | |
| # python_version: ${{ steps.set-output.outputs.python_version }} | |
| steps: | |
| - name: Checkout this repo (for builder) | |
| 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: Early check for no conflicting release | |
| uses: fpgawars/apio-workflows/.github/actions/ensure-no-conflicting-release@main | |
| with: | |
| release-tag: ${{ env.RELEASE_TAG }} | |
| just-check: true | |
| - name: Get repo info | |
| uses: fpgawars/apio-workflows/.github/actions/get-repo-info@main | |
| with: | |
| repo-dir: . | |
| branch-var: REPO_BRANCH | |
| commit-var: REPO_COMMIT | |
| - name: Get Apio version | |
| uses: fpgawars/apio-workflows/.github/actions/get-apio-version@main | |
| with: | |
| apio-repo-root: . | |
| env-var-name: APIO_VERSION | |
| # Create the build configuration that we will pass to the other jobs. | |
| - name: Create build info | |
| run: | | |
| # # Collect values | |
| # REQUESTED_COMMIT="${{ github.event.inputs.commit_sha }}" | |
| # if [ -z "$REQUESTED_COMMIT" ]; then | |
| # REQUESTED_COMMIT="(none)" | |
| # fi | |
| # Generate build-info.json | |
| cat > build-info.json <<EOF | |
| { | |
| "package-name": "apio-cli", | |
| "description" : "Command-line FPGA design suite", | |
| "apio-cli-version": "$APIO_VERSION", | |
| "apio-python-version" : "$PYTHON_VERSION", | |
| "repo": "${{github.repository}}", | |
| "repo-branch": "${REPO_BRANCH}", | |
| "repo-commit": "${REPO_COMMIT}", | |
| "release-tag": "$RELEASE_TAG", | |
| "package-tag": "$PACKAGE_TAG", | |
| "build-time": "$(date +'%Y-%m-%d %H:%M:%S %Z')", | |
| "builder-workflow": "${{ github.workflow }}", | |
| "workflow-run-id": "${{github.run_id}}", | |
| "workflow-run-number": "${{github.run_number}}" | |
| } | |
| 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: Upload the build info artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| if-no-files-found: error | |
| name: build-info | |
| path: build-info.json | |
| # ----- Children build jobs | |
| # We dispatch separate child workflows because each pyinstaller builder | |
| # needs to run on it's target architecture and have specific installer | |
| # configuration. | |
| build-darwin-arm64: | |
| needs: prepare | |
| uses: ./.github/workflows/build-darwin-arm64.yaml | |
| secrets: inherit | |
| build-darwin-x86-64: | |
| needs: prepare | |
| uses: ./.github/workflows/build-darwin-x86-64.yaml | |
| secrets: inherit | |
| build-linux-x86-64: | |
| needs: prepare | |
| uses: ./.github/workflows/build-linux-x86-64.yaml | |
| secrets: inherit | |
| build-windows-amd64: | |
| needs: prepare | |
| uses: ./.github/workflows/build-windows-amd64.yaml | |
| secrets: inherit | |
| # # ----- Release creation job | |
| release: | |
| needs: | |
| [prepare, build-darwin-arm64, prepare, build-darwin-x86-64, build-linux-x86-64, build-windows-amd64] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout this repo (for builder) | |
| uses: actions/checkout@v4 | |
| - name: Download the artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| path: _artifacts | |
| - name: Scan the packages for viruses | |
| uses: fpgawars/apio-workflows/.github/actions/scan-files-for-viruses@main | |
| with: | |
| file-patterns: | | |
| _artifacts/apio-*.* | |
| - name: Move build info | |
| run: | | |
| find _artifacts | |
| mv _artifacts/build-info.json . | |
| cat -n build-info.json | |
| - name: Set env vars from JSON | |
| uses: fpgawars/apio-workflows/.github/actions/set-env-from-json@main | |
| with: | |
| json-file: build-info.json | |
| mappings: >- | |
| APIO_VERSION apio-cli-version | |
| REPO_COMMIT repo-commit | |
| RELEASE_TAG release-tag | |
| PACKAGE_TAG package-tag | |
| - 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 | |
| - name: Create assets markdown table | |
| run: | | |
| # The common prefix of the assets urls | |
| URL_PREFIX="https://github.com/${{ github.repository }}/releases/download/$RELEASE_TAG" | |
| echo "URL_PREFIX=${URL_PREFIX}" | |
| # Write the table to a file. | |
| cat << EOF > "assets-table.md" | |
| ### Apio CLI installers | |
| | System | Architecture | Installer type | Package | | |
| | :--- | :--- | :--- | :--- | | |
| | MacOS | Apple Silicon | Wizard | [apio-cli-darwin-arm64-${PACKAGE_TAG}-installer.pkg](${URL_PREFIX}/apio-cli-darwin-arm64-${PACKAGE_TAG}-installer.pkg) | | |
| | MacOS | Intel Silicon | Wizard | [apio-cli-darwin-x86-64-${PACKAGE_TAG}-installer.pkg](${URL_PREFIX}/apio-cli-darwin-x86-64-${PACKAGE_TAG}-installer.pkg) | | |
| | Linux | X86 64 bit | Debian package | [apio-cli-linux-x86-64-${PACKAGE_TAG}-debian.deb](${URL_PREFIX}/apio-cli-linux-x86-64-${PACKAGE_TAG}-debian.deb) | | |
| | Windows | X86 64 bit | Wizard | [apio-cli-windows-amd64-${PACKAGE_TAG}-installer.exe](${URL_PREFIX}/apio-cli-windows-amd64-${PACKAGE_TAG}-installer.exe) | | |
| ### Apio CLI file bundles | |
| | System | Architecture | Package | | |
| | :--- | :--- | :--- | | |
| | MacOS | Apple Silicon | [apio-cli-darwin-arm64-${PACKAGE_TAG}-bundle.tgz](${URL_PREFIX}/apio-cli-darwin-arm64-${PACKAGE_TAG}-bundle.tgz) | | |
| | MacOS | Intel Silicon | [apio-cli-darwin-x86-64-${PACKAGE_TAG}-bundle.tgz](${URL_PREFIX}/apio-cli-darwin-x86-64-${PACKAGE_TAG}-bundle.tgz) | | |
| | Linux | X86 64 bit | [apio-cli-linux-x86-64-${PACKAGE_TAG}-bundle.tgz](${URL_PREFIX}/apio-cli-linux-x86-64-${PACKAGE_TAG}-bundle.tgz) | | |
| | Windows | X86 64 bit | [apio-cli-windows-amd64-${PACKAGE_TAG}-bundle.zip](${URL_PREFIX}/apio-cli-windows-amd64-${PACKAGE_TAG}-bundle.zip) | | |
| EOF | |
| cat -n "assets-table.md" | |
| # Summary for the workflow run page. | |
| - name: Prepare workflow run summary | |
| run: | | |
| cat > RUN-SUMMARY.txt <<EOF | |
| Build info: | |
| \`\`\` | |
| $(cat build-info.txt) | |
| \`\`\` | |
| - [Apio CLI cutoff commit](https://github.com/${{ github.repository }}/commit/${REPO_COMMIT}) | |
| - [Generated Apio CLI 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 | |
| # Notes for the release page. | |
| - 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. | |
| ### Installation | |
| To install Apio CLI from the files below, please follow \ | |
| the [Apio CLI installation guide](https://fpgawars.github.io/apio/docs/installing-apio-cli), | |
| as additional manual steps may be required for a successful installation. | |
| $(cat assets-table.md) | |
| ### 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 (again) | |
| 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: | | |
| _artifacts/apio-cli-darwin-arm64-${{env.PACKAGE_TAG}}-bundle.tgz | |
| _artifacts/apio-cli-darwin-arm64-${{env.PACKAGE_TAG}}-installer.pkg | |
| _artifacts/apio-cli-darwin-x86-64-${{env.PACKAGE_TAG}}-bundle.tgz | |
| _artifacts/apio-cli-darwin-x86-64-${{env.PACKAGE_TAG}}-installer.pkg | |
| _artifacts/apio-cli-linux-x86-64-${{env.PACKAGE_TAG}}-bundle.tgz | |
| _artifacts/apio-cli-linux-x86-64-${{env.PACKAGE_TAG}}-debian.deb | |
| _artifacts/apio-cli-windows-amd64-${{env.PACKAGE_TAG}}-bundle.zip | |
| _artifacts/apio-cli-windows-amd64-${{env.PACKAGE_TAG}}-installer.exe |