diff --git a/.gitea/workflows/build-kernel.yml b/.gitea/workflows/build-kernel.yml index 809a2f6..83224ac 100644 --- a/.gitea/workflows/build-kernel.yml +++ b/.gitea/workflows/build-kernel.yml @@ -99,14 +99,14 @@ jobs: path: kernel/out if-no-files-found: error - # Release flow only: merges all built modules into one modules/ folder, wraps it - # in a single repo-named top folder alongside the helper scripts (selftest.sh, - # launch.sh) and the iecpoc Python frontend (so launch.sh can pip-install it on - # the Pi), zips it and attaches it to the Gitea release for the pushed tag. - # Skipped entirely on pull requests. - release: + # Merge all built modules into one modules/ folder, wrap it in a single + # repo-named top folder alongside the helper scripts (selftest.sh, launch.sh) + # and the iecpoc Python frontend (so launch.sh can pip-install it on the Pi), + # and zip it. Runs on BOTH triggers and uploads the zip as an artifact: on a PR + # this lets you download and smoke-test the exact archive a release would ship; + # on a tag the release job below republishes this same artifact unchanged. + package: needs: build - if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest steps: - name: Checkout @@ -116,10 +116,20 @@ jobs: uses: https://github.com/christopherHX/gitea-download-artifact@v4 with: path: dist - # Merge every artifact back into the shared modules/ folder. + # Merge every per-kernel artifact back into the shared modules/ folder. merge-multiple: true - - name: Assemble release package + - name: Determine version label + id: ver + run: | + # Tags ship under the tag name; PR builds get a traceable pr-. + case "${{ github.ref }}" in + refs/tags/*) v="${{ github.ref_name }}" ;; + *) v="pr${{ github.event.pull_request.number }}-$(echo "${{ github.sha }}" | cut -c1-7)" ;; + esac + echo "ver=$v" >> "$GITHUB_OUTPUT" + + - name: Assemble package zip run: | repo="${{ github.event.repository.name }}" root="package/$repo" @@ -133,11 +143,32 @@ jobs: cp pyproject.toml README.md "$root"/ cp -r iecpoc "$root"/ find "$root/iecpoc" -name __pycache__ -type d -prune -exec rm -rf {} + - (cd package && zip -r "../${repo}-${{ github.ref_name }}.zip" "$repo") + (cd package && zip -r "../${repo}-${{ steps.ver.outputs.ver }}.zip" "$repo") + + - name: Upload package zip + uses: https://github.com/christopherHX/gitea-upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-${{ steps.ver.outputs.ver }} + path: ${{ github.event.repository.name }}-*.zip + if-no-files-found: error + + # Release flow only: takes the zip the package job already built and attaches it + # to the Gitea release for the pushed tag. No re-assembly here. Skipped on PRs. + release: + needs: package + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Download package zip + uses: https://github.com/christopherHX/gitea-download-artifact@v4 + with: + # The single artifact the package job produced for this tag. + name: ${{ github.event.repository.name }}-${{ github.ref_name }} + path: dist - name: Publish to Gitea release uses: https://gitea.com/actions/gitea-release-action@v1.3.6 with: api_key: ${{ secrets.GITEA_TOKEN }} files: |- - *.zip + dist/*.zip