diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..9440cc0 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,57 @@ +name: Auto release + +# Publish the release for a merged CachyOS pin PR after the full build matrix +# on main has passed. The pin workflow already bumped VERSION in the PR. +on: + workflow_run: + workflows: ["Test kernel install"] + types: [completed] + branches: [main] + +permissions: + contents: write + +jobs: + release: + if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + fetch-depth: 0 + - name: Check for a CachyOS pin merge + id: pin + run: | + if git log -1 --format='%s%n%b' | grep -q 'pin CachyOS\|chore/cachyos-pin'; then + echo "release=true" >> "$GITHUB_OUTPUT" + else + echo "release=false" >> "$GITHUB_OUTPUT" + fi + - name: Tag and publish + if: steps.pin.outputs.release == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + version=$(grep -m1 '^VERSION=' kernel_installer.sh | cut -d\' -f2) + if git rev-parse "v${version}" >/dev/null 2>&1; then + echo "v${version} already exists; nothing to do" + exit 0 + fi + cachyos=$(grep -m1 '^CACHYOS_VERSION=' kernel_installer.sh | cut -d= -f2) + tagrel=$(grep -m1 '^CACHYOS_TAGREL=' kernel_installer.sh | cut -d= -f2) + git config user.name 'tmiland-lab[bot]' + git config user.email '326116980+tmiland-lab[bot]@users.noreply.github.com' + git tag -a "v${version}" -m "kernel-installer ${version}" + git push origin "v${version}" + notes=$(mktemp) + { + echo "Automated release for CachyOS ${cachyos}-${tagrel}." + echo + echo "Full build matrix passed: ${{ github.event.workflow_run.html_url }}" + } > "$notes" + gh release create "v${version}" --repo "$GITHUB_REPOSITORY" \ + --title "v${version}" --notes-file "$notes" + sha256sum kernel_installer.sh > SHA256SUMS + gh release upload "v${version}" kernel_installer.sh SHA256SUMS --clobber diff --git a/.github/workflows/pin-cachyos.yml b/.github/workflows/pin-cachyos.yml index 0f9aebb..249df47 100644 --- a/.github/workflows/pin-cachyos.yml +++ b/.github/workflows/pin-cachyos.yml @@ -52,25 +52,36 @@ jobs: config_sha=$(grep -m1 '^CACHYOS_CONFIG_SHA256=' kernel_installer.sh | cut -d= -f2) bore_sha=$(grep -m1 '^CACHYOS_BORE_PATCH_SHA256=' kernel_installer.sh | cut -d= -f2) bmq_sha=$(grep -m1 '^CACHYOS_BMQ_PATCH_SHA256=' kernel_installer.sh | cut -d= -f2) + current=$(grep -m1 '^VERSION=' kernel_installer.sh | cut -d\' -f2) + major=${current%%.*} + rest=${current#*.} + minor=${rest%%.*} + patch=${rest#*.} + next="${major}.${minor}.$((10#${patch} + 1))" + sed -i "s/^VERSION='${current}'/VERSION='${next}'/" kernel_installer.sh + sed -i "s/Script version: ${current}/Script version: ${next}/" README.md branch=chore/cachyos-pin git checkout -B "$branch" git add kernel_installer.sh README.md tests/test_cachyos_cli.sh .github/workflows/test-install.yml - git commit -m "chore: pin CachyOS ${version}-${tagrel}" -m "Automated pin update from the latest stable CachyOS release. Config-only BORE validation passed." + git commit -m "chore: pin CachyOS ${version}-${tagrel} (release ${next})" -m "Automated pin update from the latest stable CachyOS release. Config-only BORE validation passed." git push --force origin "$branch" - if gh pr list --head "$branch" --state open --json number --jq '.[0].number' | grep -q .; then - echo "Updated the open pin PR" - exit 0 + pr=$(gh pr list --head "$branch" --state open --json number --jq '.[0].number') + if [ -z "$pr" ]; then + body=$(mktemp) + printf '%s\n' \ + "Automated CachyOS pin update." \ + "" \ + "- source: \`cachyos-${version}-${tagrel}\`" \ + "- config SHA256: \`${config_sha}\`" \ + "- BORE SHA256: \`${bore_sha}\`" \ + "- BMQ SHA256: \`${bmq_sha}\`" \ + "- release: \`v${next}\` after the full matrix passes" \ + "" \ + "The config-only BORE validation passed." > "$body" + gh pr create --base main --head "$branch" \ + --title "chore: pin CachyOS ${version}-${tagrel} (release ${next})" \ + --body-file "$body" + pr=$(gh pr list --head "$branch" --state open --json number --jq '.[0].number') fi - body=$(mktemp) - printf '%s\n' \ - "Automated CachyOS pin update." \ - "" \ - "- source: \`cachyos-${version}-${tagrel}\`" \ - "- config SHA256: \`${config_sha}\`" \ - "- BORE SHA256: \`${bore_sha}\`" \ - "- BMQ SHA256: \`${bmq_sha}\`" \ - "" \ - "The config-only BORE validation passed." > "$body" - gh pr create --base main --head "$branch" \ - --title "chore: pin CachyOS ${version}-${tagrel}" \ - --body-file "$body" + gh pr checks "$pr" --watch + gh pr merge "$pr" --merge --delete-branch diff --git a/README.md b/README.md index 5b4078d..4ce7543 100644 --- a/README.md +++ b/README.md @@ -613,14 +613,24 @@ Tested and working on: Debian 12/13, Ubuntu 22.04/24.04 and Fedora 44 (see [test ### Pinning CachyOS The scheduled `Pin CachyOS` workflow checks the latest stable CachyOS release -weekly and opens a PR with the new source, config, and BORE/BMQ patch pins. -The PR runs the fast config-only checks; merging keeps the pinned default and -CI current. Users who want the newest release immediately can use -`--cachyos-latest` without waiting for the pin. - -The workflow uses the repository `GITHUB_TOKEN`; enable -Settings → Actions → General → Allow GitHub Actions to create and approve pull -requests for the PR step. +weekly, updates the source/config/BORE/BMQ pins, bumps the patch version, and +validates the configuration. It opens a PR, waits for the fast checks, and +merges it automatically. The `Auto release` workflow then waits for the full +build matrix on `main`, tags the merged commit, and publishes the release with +`kernel_installer.sh` and `SHA256SUMS`. + +One-time repository settings: + +- Settings → Actions → General → Allow GitHub Actions to create and approve + pull requests. +- A `main` branch protection that does not require a human approval for the + bot's pin PR; the fast checks still gate the merge. +- The auto-release is created by `github-actions[bot]` and uploads its own + assets, because a token-created release does not trigger the `Release assets` + workflow. + +Users who want the newest release immediately can use `--cachyos-latest` +without waiting for the pin. ### Updating the vendored slib