build-pre-release #193
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: | |
| # prevents warnings in the vscode editor. | |
| RELEASE_TAG: "" | |
| PACKAGE_TAG: "" | |
| VSCODE_EXTENSION_VERSION: "" | |
| APIO_CLI_RELEASE_REPO: "" | |
| APIO_CLI_RELEASE_TAG: "" | |
| jobs: | |
| # ----- Parameters collection job | |
| build-pre-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout this repo | |
| uses: actions/checkout@v4 | |
| - name: List repo files | |
| run: | | |
| ls -al | |
| - 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: Determine package file name | |
| run: | | |
| package_name="apio-vscode-${PACKAGE_TAG}.vsix" | |
| echo "PACKAGE_NAME=$package_name" | |
| echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: "package.json" # Detects from engines.node | |
| - name: Verify npx | |
| run: npx --version | |
| - name: List repo files | |
| run: | | |
| ls -al | |
| - name: Extract values and set environment variables | |
| run: | | |
| const workspace = process.env.GITHUB_WORKSPACE; | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const constants = require(path.join(workspace, 'src', 'constants.js')); | |
| const pkg = require(path.join(workspace, 'package.json')); | |
| const envPath = process.env.GITHUB_ENV; | |
| console.log(`VSCODE_EXTENSION_VERSION=${pkg.version}`) | |
| fs.appendFileSync(envPath, `VSCODE_EXTENSION_VERSION=${pkg.version}\n`); | |
| console.log(`APIO_CLI_RELEASE_REPO=${constants.APIO_CLI_RELEASE_REPO}`) | |
| fs.appendFileSync(envPath, `APIO_CLI_RELEASE_REPO=${constants.APIO_CLI_RELEASE_REPO}\n`); | |
| console.log(`APIO_CLI_RELEASE_TAG=${constants.APIO_CLI_RELEASE_TAG}`) | |
| fs.appendFileSync(envPath, `APIO_CLI_RELEASE_TAG=${constants.APIO_CLI_RELEASE_TAG}\n`); | |
| shell: node {0} | |
| # Create the build info file that we will include in the package. | |
| - name: Create build info | |
| run: | | |
| # Generate build-info.json | |
| cat > build-info.json <<EOF | |
| { | |
| "package-name": "apio-ide", | |
| "description" : "Apio extension for Visual Studio Code", | |
| "source-repo": "${{github.repository}}", | |
| "source-sha": "${{ github.sha }}", | |
| "source-branch": "${{ github.ref_name }}", | |
| "apio-ide-version": "$VSCODE_EXTENSION_VERSION", | |
| "apio-ide-release-tag": "${RELEASE_TAG}", | |
| "apio-cli-release-repo": "$APIO_CLI_RELEASE_REPO", | |
| "apio-cli-release-tag" : "$APIO_CLI_RELEASE_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: Build the .vsix file | |
| run: | | |
| ./scripts/build.sh | |
| - name: Rename package file | |
| run: | | |
| mv apio*.vsix $PACKAGE_NAME | |
| ls -al | |
| - name: Show packaged files | |
| run: | | |
| unzip -l $PACKAGE_NAME | |
| - 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) | |
| \`\`\` | |
| - [Apio IDE cutoff commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) | |
| - [Linked Apio CLI release](https://github.com/${APIO_CLI_RELEASE_REPO}/releases/tag/${APIO_CLI_RELEASE_TAG}) \ | |
| (Must exist for this Apio IDE release to work) | |
| - [Generated Apio IDE 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 | |
| # Add notes for the release page. | |
| - name: Create the 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. | |
| ### Dependency note | |
| This Apio IDE release is hard coded to fetch the Apio binary from \ | |
| [Apio CLI release $APIO_CLI_RELEASE_TAG](https://github.com/$APIO_CLI_RELEASE_REPO/releases/tag/$APIO_CLI_RELEASE_TAG) \ | |
| which must exist for this VS Code extension to be functional. | |
| ### Installation | |
| This VS Code extension is typically installed directly from the VS Code Marketplace \ | |
| [where it's published](https://marketplace.visualstudio.com/items?itemName=fpgawars.apio). \ | |
| To side load the .vsix file from here use the VS Code \ | |
| \`Install from VSIX\` command in the extensions menu. | |
| ### 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-vscode-${{env.PACKAGE_TAG}}.vsix |