Make and Release #21
Workflow file for this run
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: make and release | |
| run-name: Make and Release | |
| permissions: | |
| contents: write | |
| discussions: write | |
| # on: workflow_dispatch | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| check-ci-status: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get-version.outputs.version }} | |
| commit-sha: ${{ steps.get-version.outputs.commit-sha }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version and commit from tag | |
| id: get-version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| COMMIT_SHA=$(git rev-list -n 1 $GITHUB_REF) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "commit-sha=$COMMIT_SHA" >> $GITHUB_OUTPUT | |
| echo "Tag version: $VERSION" | |
| echo "Tag points to commit: $COMMIT_SHA" | |
| - name: Check if commit is on master or beta branch | |
| if: ${{ !contains(steps.get-version.outputs.version, 'test') }} | |
| run: | | |
| COMMIT_SHA="${{ steps.get-version.outputs.commit-sha }}" | |
| BRANCHES=$(git branch -r --contains $COMMIT_SHA | grep -E 'origin/(master|beta)' || true) | |
| if [ -z "$BRANCHES" ]; then | |
| echo "Error: Tag commit $COMMIT_SHA is not on master or beta branch" | |
| echo "CI only runs on master/beta branches" | |
| exit 1 | |
| fi | |
| echo "Commit is on branch(es): $BRANCHES" | |
| - name: Wait for CI to pass | |
| if: ${{ !contains(steps.get-version.outputs.version, 'test') }} | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const taggedCommit = '${{ steps.get-version.outputs.commit-sha }}'; | |
| console.log('Checking CI status for tagged commit:', taggedCommit); | |
| // Wait for CI workflow to complete (max 30 minutes) | |
| const maxAttempts = 180; // 30 minutes with 10 second intervals | |
| let attempts = 0; | |
| while (attempts < maxAttempts) { | |
| const runs = await github.rest.actions.listWorkflowRuns({ | |
| owner, | |
| repo, | |
| workflow_id: 'ci.yml', | |
| head_sha: taggedCommit, | |
| per_page: 5 | |
| }); | |
| if (runs.data.workflow_runs.length > 0) { | |
| // Find the CI run that matches our commit exactly | |
| const matchingRun = runs.data.workflow_runs.find(run => run.head_sha === taggedCommit); | |
| if (matchingRun) { | |
| console.log(`CI workflow status: ${matchingRun.status}, conclusion: ${matchingRun.conclusion}`); | |
| console.log(`CI run URL: ${matchingRun.html_url}`); | |
| if (matchingRun.status === 'completed') { | |
| if (matchingRun.conclusion === 'success') { | |
| console.log('CI passed successfully!'); | |
| return; | |
| } else { | |
| core.setFailed(`CI failed with conclusion: ${matchingRun.conclusion}\nSee: ${matchingRun.html_url}`); | |
| return; | |
| } | |
| } | |
| } else { | |
| console.log(`No CI run found yet for commit ${taggedCommit}`); | |
| } | |
| } | |
| console.log(`Waiting for CI... (attempt ${attempts + 1}/${maxAttempts})`); | |
| await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds | |
| attempts++; | |
| } | |
| core.setFailed(`Timeout waiting for CI to complete for commit ${taggedCommit}\nMake sure CI ran on master/beta branch for this commit`); | |
| buildLinux: | |
| needs: check-ci-status | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.check-ci-status.outputs.commit-sha }} | |
| fetch-depth: 0 | |
| - uses: pnpm/action-setup@v4 | |
| name: Setup pnpm | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18.15.0 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Install dpkg-deb for pacman package creation | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y dpkg-dev | |
| - name: forge make deb | |
| run: pnpm make:deb | |
| - name: Set version | |
| id: version | |
| run: | | |
| VERSION="${{ needs.check-ci-status.outputs.version }}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Building version: $VERSION" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build-files | |
| path: | | |
| ./out/all/* | |
| ./build-artifacts/* | |
| if-no-files-found: error | |
| build: | |
| needs: [check-ci-status, buildLinux] | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.check-ci-status.outputs.commit-sha }} | |
| fetch-depth: 0 | |
| - uses: pnpm/action-setup@v4 | |
| name: Setup pnpm | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18.15.0 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - uses: actions/download-artifact@v4 | |
| id: linux-build-files-downloader | |
| with: | |
| name: linux-build-files | |
| path: ./linux-artifacts/ | |
| merge-multiple: true | |
| - name: Move Linux artifacts and build artifacts | |
| shell: bash | |
| run: | | |
| if [ -d "./linux-artifacts/out/all" ]; then | |
| mkdir -p ./out/all | |
| cp -r ./linux-artifacts/out/all/* ./out/all/ || true | |
| fi | |
| if [ -d "./linux-artifacts/build-artifacts" ]; then | |
| mkdir -p ./build-artifacts | |
| cp -r ./linux-artifacts/build-artifacts/* ./build-artifacts/ || true | |
| fi | |
| - name: Build for windows | |
| run: | | |
| pnpm make:win32 | |
| pnpm make:win64 | |
| - name: Generate release artifacts | |
| run: pnpm generate:release | |
| - name: Set version | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION="${{ needs.check-ci-status.outputs.version }}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Building version: $VERSION" | |
| - name: Read files-to-upload.txt | |
| id: files-to-upload | |
| shell: bash | |
| run: | | |
| echo "files=$(cat files-to-upload.txt)" >> $GITHUB_OUTPUT | |
| - name: Make changelog | |
| id: changelog | |
| shell: bash | |
| run: | | |
| cat download-btns.txt >> changelog-temp.md | |
| echo $'\n---\n\n' >> changelog-temp.md | |
| cat changelog.md >> changelog-temp.md | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{steps.version.outputs.version}} | |
| name: ${{steps.version.outputs.version}} | |
| files: | | |
| ./out/all/* | |
| ./artifacts.json | |
| ./checksums.txt | |
| body_path: changelog-temp.md | |
| generate_release_notes: true | |
| discussion_category_name: General | |
| prerelease: ${{ contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'alpha') || contains(steps.version.outputs.version, 'test') }} |