From c4dd8488fe46543d5727674f8f0b856823115e32 Mon Sep 17 00:00:00 2001 From: objz Date: Sun, 12 Jul 2026 18:47:49 +0200 Subject: [PATCH] ci: simplify release workflows --- .github/workflows/build-release.yml | 427 ++++++++++++++++++ .github/workflows/build.yml | 55 ++- .github/workflows/publish-chocolatey.yml | 107 ----- .github/workflows/release.yml | 493 ++------------------- .github/workflows/tag-release.yml | 94 ---- README.md | 9 +- cliff.toml | 32 +- dist-workspace.toml | 4 +- pkg/chocolatey/rmcl.nuspec | 24 - pkg/chocolatey/tools/chocolateyInstall.ps1 | 14 - src/tui/event.rs | 6 +- src/tui/widgets/content/list.rs | 7 +- 12 files changed, 534 insertions(+), 738 deletions(-) create mode 100644 .github/workflows/build-release.yml delete mode 100644 .github/workflows/publish-chocolatey.yml delete mode 100644 .github/workflows/tag-release.yml delete mode 100644 pkg/chocolatey/rmcl.nuspec delete mode 100644 pkg/chocolatey/tools/chocolateyInstall.ps1 diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..c5c7b40 --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,427 @@ +# cargo-dist artifact building and publishing, called by release.yml. +# Based on cargo-dist's generated GitHub workflow. + +name: build release +permissions: + "contents": "write" + +on: + workflow_call: + inputs: + tag: + required: true + type: string + +jobs: + # Run 'dist plan' (or host) to determine what tasks we need to do + plan: + runs-on: "ubuntu-22.04" + outputs: + val: ${{ steps.plan.outputs.manifest }} + tag: ${{ inputs.tag }} + tag-flag: ${{ format('--tag={0}', inputs.tag) }} + publishing: true + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.tag }} + persist-credentials: false + submodules: recursive + - name: Install dist + # we specify bash to get pipefail; it guards against the `curl` command + # failing. otherwise `sh` won't catch that `curl` returned non-0 + shell: bash + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh" + - name: Cache dist + uses: actions/upload-artifact@v6 + with: + name: cargo-dist-cache + path: ~/.cargo/bin/dist + # sure would be cool if github gave us proper conditionals... + # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible + # functionality based on whether this is a pull_request, and whether it's from a fork. + # (PRs run on the *source* but secrets are usually on the *target* -- that's *good* + # but also really annoying to build CI around when it needs secrets to work right.) + - id: plan + run: | + dist host --steps=create --tag=${{ inputs.tag }} --output-format=json > plan-dist-manifest.json + echo "dist ran successfully" + cat plan-dist-manifest.json + echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v6 + with: + name: artifacts-plan-dist-manifest + path: plan-dist-manifest.json + + # Build and packages all the platform-specific things + build-local-artifacts: + name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) + # Let the initial task tell us to not run (currently very blunt) + needs: + - plan + if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} + strategy: + fail-fast: false + # Target platforms/runners are computed by dist in create-release. + # Each member of the matrix has the following arguments: + # + # - runner: the github runner + # - dist-args: cli flags to pass to dist + # - install-dist: expression to run to install dist on the runner + # + # Typically there will be: + # - 1 "global" task that builds universal installers + # - N "local" tasks that build each platform's binaries and platform-specific installers + matrix: ${{ fromJson(needs.plan.outputs.val || '{"ci":{"github":{"artifacts_matrix":{"include":[]}}}}').ci.github.artifacts_matrix }} + runs-on: ${{ matrix.runner }} + container: ${{ matrix.container && matrix.container.image || null }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json + steps: + - name: enable windows longpaths + run: | + git config --global core.longpaths true + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.tag }} + persist-credentials: false + submodules: recursive + - name: Install Rust non-interactively if not already installed + if: ${{ matrix.container }} + run: | + if ! command -v cargo > /dev/null 2>&1; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + fi + - name: "install JDK" + uses: "actions/setup-java@v5" + with: + "distribution": "temurin" + "java-version": "21" + - name: Install dist + run: ${{ matrix.install_dist.run }} + # Get the dist-manifest + - name: Fetch local artifacts + uses: actions/download-artifact@v7 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - name: Install dependencies + run: | + ${{ matrix.packages_install }} + - name: Build artifacts + run: | + # Actually do builds and make zips and whatnot + dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json + echo "dist ran successfully" + - id: cargo-dist + name: Post-build + # We force bash here just because github makes it really hard to get values up + # to "real" actions without writing to env-vars, and writing to env-vars has + # inconsistent syntax between shell and powershell. + shell: bash + run: | + # Parse out what we just built and upload it to scratch storage + echo "paths<> "$GITHUB_OUTPUT" + dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + cp dist-manifest.json "$BUILD_MANIFEST_NAME" + - name: "Upload artifacts" + uses: actions/upload-artifact@v6 + with: + name: artifacts-build-local-${{ join(matrix.targets, '_') }} + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} + + # Build and package all the platform-agnostic(ish) things + build-global-artifacts: + needs: + - plan + - build-local-artifacts + runs-on: "ubuntu-22.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.tag }} + persist-credentials: false + submodules: recursive + - name: Install cached dist + uses: actions/download-artifact@v7 + with: + name: cargo-dist-cache + path: ~/.cargo/bin/ + - run: chmod +x ~/.cargo/bin/dist + # Get all the local artifacts for the global tasks to use (for e.g. checksums) + - name: Fetch local artifacts + uses: actions/download-artifact@v7 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - id: cargo-dist + shell: bash + run: | + dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json + echo "dist ran successfully" + + # Parse out what we just built and upload it to scratch storage + echo "paths<> "$GITHUB_OUTPUT" + jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + cp dist-manifest.json "$BUILD_MANIFEST_NAME" + - name: "Upload artifacts" + uses: actions/upload-artifact@v6 + with: + name: artifacts-build-global + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} + # Determines if we should publish/announce + host: + needs: + - plan + - build-local-artifacts + - build-global-artifacts + # Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine) + if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + runs-on: "ubuntu-22.04" + outputs: + val: ${{ steps.host.outputs.manifest }} + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.tag }} + persist-credentials: false + submodules: recursive + fetch-depth: 0 + fetch-tags: true + - name: Install cached dist + uses: actions/download-artifact@v7 + with: + name: cargo-dist-cache + path: ~/.cargo/bin/ + - run: chmod +x ~/.cargo/bin/dist + # Fetch artifacts from scratch-storage + - name: Fetch artifacts + uses: actions/download-artifact@v7 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - id: host + shell: bash + run: | + dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json + echo "artifacts uploaded and released successfully" + cat dist-manifest.json + echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v6 + with: + # Overwrite the previous copy + name: artifacts-dist-manifest + path: dist-manifest.json + # Create a GitHub Release while uploading all files to it + - name: "Download GitHub Artifacts" + uses: actions/download-artifact@v7 + with: + pattern: artifacts-* + path: artifacts + merge-multiple: true + - name: Cleanup + run: | + # Remove internal cargo-dist manifests from the public GitHub Release. + rm -f artifacts/*-dist-manifest.json artifacts/dist-manifest.json + - name: Generate changelog + id: changelog + uses: orhun/git-cliff-action@v4 + with: + args: --latest --strip header + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create GitHub Release + env: + PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}" + ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}" + RELEASE_COMMIT: "${{ inputs.tag }}" + CHANGELOG: "${{ steps.changelog.outputs.content }}" + RELEASE_TAG: "${{ needs.plan.outputs.tag }}" + APP_VERSION: "${{ fromJson(steps.host.outputs.manifest).releases[0].app_version }}" + run: | + echo "$CHANGELOG" > $RUNNER_TEMP/notes.txt + cat >> $RUNNER_TEMP/notes.txt <> "$GITHUB_OUTPUT" - echo "package_dir=$package_dir" >> "$GITHUB_OUTPUT" - - - name: pack Chocolatey package - uses: crazy-max/ghaction-chocolatey@v4 - with: - args: pack ${{ steps.package.outputs.package_dir }}/rmcl.nuspec --version ${{ steps.package.outputs.version }} --output-directory target/chocolatey/out - - - name: push Chocolatey package - shell: bash - run: | - package="target/chocolatey/out/rmcl.${{ steps.package.outputs.version }}.nupkg" - version="${{ steps.package.outputs.version }}" - public_package_url="https://community.chocolatey.org/packages/rmcl/$version" - saw_server_error=false - - for attempt in 1 2 3; do - log_file="$RUNNER_TEMP/chocolatey-push-${attempt}.log" - - if docker run --rm --workdir /wksp --volume "$PWD:/wksp" ghcr.io/crazy-max/chocolatey push "$package" --source "https://push.chocolatey.org/" --api-key "$CHOCOLATEY_API_KEY" --timeout 2700 2>&1 | tee "$log_file"; then - exit 0 - fi - - if grep -q "409 (Conflict)" "$log_file"; then - echo "::warning::Chocolatey package version already exists; treating this publish as complete." - exit 0 - fi - - if grep -qE "50[0-9] \\(" "$log_file"; then - saw_server_error=true - fi - - if grep -q "403 (Forbidden)" "$log_file"; then - if [ "$saw_server_error" = "true" ]; then - echo "::warning::Chocolatey returned 403 after an earlier server error. The previous push may have been accepted and put into moderation; treating this publish as complete." - exit 0 - fi - - page_file="$RUNNER_TEMP/chocolatey-package-$version.html" - page_status="$(curl --location --silent --show-error --output "$page_file" --write-out "%{http_code}" "$public_package_url")" - - if [ "$page_status" = "200" ] && grep -qE "awaiting moderation|remain unlisted until it has been approved|Version History" "$page_file"; then - echo "::warning::Chocolatey returned 403, but the public package page for version $version exists and is awaiting moderation; treating this publish as complete." - exit 0 - fi - - echo "::error::Chocolatey rejected the push with 403 before any server-side failure. Check CHOCOLATEY_API_KEY ownership/permissions for rmcl." - exit 1 - fi - - if [ "$attempt" -eq 3 ]; then - break - fi - - sleep $((attempt * 30)) - done - - exit 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d56383..1c97f25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,472 +1,69 @@ -# This file was autogenerated by dist: https://axodotdev.github.io/cargo-dist -# -# Copyright 2022-2024, axodotdev -# SPDX-License-Identifier: MIT or Apache-2.0 -# -# CI that: -# -# * checks for a Git Tag that looks like a release -# * builds artifacts with dist (archives, installers, hashes) -# * uploads those artifacts to temporary workflow zip -# * on success, uploads the artifacts to a GitHub Release -# -# Note that the GitHub Release will be created with a generated -# title/body based on your changelogs. - name: release -permissions: - "contents": "write" -# This task will run whenever you push a git tag that looks like a version -# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc. -# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where -# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION -# must be a Cargo-style SemVer Version (must have at least major.minor.patch). -# -# If PACKAGE_NAME is specified, then the announcement will be for that -# package (erroring out if it doesn't have the given version or isn't dist-able). -# -# If PACKAGE_NAME isn't specified, then the announcement will be for all -# (dist-able) packages in the workspace with that version (this mode is -# intended for workspaces with only one dist-able package, or with all dist-able -# packages versioned/released in lockstep). -# -# If you push multiple tags at once, separate instances of this workflow will -# spin up, creating an independent announcement for each one. However, GitHub -# will hard limit this to 3 tags per commit, as it will assume more tags is a -# mistake. -# -# If there's a prerelease-style suffix to the version, then the release(s) -# will be marked as a prerelease. on: - pull_request: workflow_dispatch: - push: - tags: - - '**[0-9]+.[0-9]+.[0-9]+*' + +permissions: + contents: write + +concurrency: + group: release + cancel-in-progress: false jobs: - # Run 'dist plan' (or host) to determine what tasks we need to do - plan: - runs-on: "ubuntu-22.04" + prepare: + runs-on: ubuntu-latest outputs: - val: ${{ steps.plan.outputs.manifest }} - tag: ${{ !github.event.pull_request && github.ref_name || '' }} - tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} - publishing: ${{ !github.event.pull_request }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + release: ${{ steps.version.outputs.release }} + tag: ${{ steps.version.outputs.tag }} steps: - uses: actions/checkout@v6 with: - persist-credentials: false - submodules: recursive - - name: Install dist - # we specify bash to get pipefail; it guards against the `curl` command - # failing. otherwise `sh` won't catch that `curl` returned non-0 - shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh" - - name: Cache dist - uses: actions/upload-artifact@v6 - with: - name: cargo-dist-cache - path: ~/.cargo/bin/dist - # sure would be cool if github gave us proper conditionals... - # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible - # functionality based on whether this is a pull_request, and whether it's from a fork. - # (PRs run on the *source* but secrets are usually on the *target* -- that's *good* - # but also really annoying to build CI around when it needs secrets to work right.) - - id: plan - run: | - dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json - echo "dist ran successfully" - cat plan-dist-manifest.json - echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" - - name: "Upload dist-manifest.json" - uses: actions/upload-artifact@v6 - with: - name: artifacts-plan-dist-manifest - path: plan-dist-manifest.json - - # Build and packages all the platform-specific things - build-local-artifacts: - name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) - # Let the initial task tell us to not run (currently very blunt) - needs: - - plan - if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} - strategy: - fail-fast: false - # Target platforms/runners are computed by dist in create-release. - # Each member of the matrix has the following arguments: - # - # - runner: the github runner - # - dist-args: cli flags to pass to dist - # - install-dist: expression to run to install dist on the runner - # - # Typically there will be: - # - 1 "global" task that builds universal installers - # - N "local" tasks that build each platform's binaries and platform-specific installers - matrix: ${{ fromJson(needs.plan.outputs.val || '{"ci":{"github":{"artifacts_matrix":{"include":[]}}}}').ci.github.artifacts_matrix }} - runs-on: ${{ matrix.runner }} - container: ${{ matrix.container && matrix.container.image || null }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json - steps: - - name: enable windows longpaths - run: | - git config --global core.longpaths true - - uses: actions/checkout@v6 - with: - persist-credentials: false - submodules: recursive - - name: Install Rust non-interactively if not already installed - if: ${{ matrix.container }} - run: | - if ! command -v cargo > /dev/null 2>&1; then - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - fi - - name: "install JDK" - uses: "actions/setup-java@v5" - with: - "distribution": "temurin" - "java-version": "21" - - name: Install dist - run: ${{ matrix.install_dist.run }} - # Get the dist-manifest - - name: Fetch local artifacts - uses: actions/download-artifact@v7 - with: - pattern: artifacts-* - path: target/distrib/ - merge-multiple: true - - name: Install dependencies - run: | - ${{ matrix.packages_install }} - - name: Build artifacts - run: | - # Actually do builds and make zips and whatnot - dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json - echo "dist ran successfully" - - id: cargo-dist - name: Post-build - # We force bash here just because github makes it really hard to get values up - # to "real" actions without writing to env-vars, and writing to env-vars has - # inconsistent syntax between shell and powershell. - shell: bash - run: | - # Parse out what we just built and upload it to scratch storage - echo "paths<> "$GITHUB_OUTPUT" - dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" - - cp dist-manifest.json "$BUILD_MANIFEST_NAME" - - name: "Upload artifacts" - uses: actions/upload-artifact@v6 - with: - name: artifacts-build-local-${{ join(matrix.targets, '_') }} - path: | - ${{ steps.cargo-dist.outputs.paths }} - ${{ env.BUILD_MANIFEST_NAME }} - - # Build and package all the platform-agnostic(ish) things - build-global-artifacts: - needs: - - plan - - build-local-artifacts - runs-on: "ubuntu-22.04" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json - steps: - - uses: actions/checkout@v6 - with: - persist-credentials: false - submodules: recursive - - name: Install cached dist - uses: actions/download-artifact@v7 - with: - name: cargo-dist-cache - path: ~/.cargo/bin/ - - run: chmod +x ~/.cargo/bin/dist - # Get all the local artifacts for the global tasks to use (for e.g. checksums) - - name: Fetch local artifacts - uses: actions/download-artifact@v7 - with: - pattern: artifacts-* - path: target/distrib/ - merge-multiple: true - - id: cargo-dist - shell: bash - run: | - dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json - echo "dist ran successfully" - - # Parse out what we just built and upload it to scratch storage - echo "paths<> "$GITHUB_OUTPUT" - jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" - - cp dist-manifest.json "$BUILD_MANIFEST_NAME" - - name: "Upload artifacts" - uses: actions/upload-artifact@v6 - with: - name: artifacts-build-global - path: | - ${{ steps.cargo-dist.outputs.paths }} - ${{ env.BUILD_MANIFEST_NAME }} - # Determines if we should publish/announce - host: - needs: - - plan - - build-local-artifacts - - build-global-artifacts - # Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine) - if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - runs-on: "ubuntu-22.04" - outputs: - val: ${{ steps.host.outputs.manifest }} - steps: - - uses: actions/checkout@v6 - with: - persist-credentials: false - submodules: recursive + ref: master fetch-depth: 0 fetch-tags: true - - name: Install cached dist - uses: actions/download-artifact@v7 - with: - name: cargo-dist-cache - path: ~/.cargo/bin/ - - run: chmod +x ~/.cargo/bin/dist - # Fetch artifacts from scratch-storage - - name: Fetch artifacts - uses: actions/download-artifact@v7 - with: - pattern: artifacts-* - path: target/distrib/ - merge-multiple: true - - id: host + + - name: check version + id: version shell: bash run: | - dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json - echo "artifacts uploaded and released successfully" - cat dist-manifest.json - echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" - - name: "Upload dist-manifest.json" - uses: actions/upload-artifact@v6 - with: - # Overwrite the previous copy - name: artifacts-dist-manifest - path: dist-manifest.json - # Create a GitHub Release while uploading all files to it - - name: "Download GitHub Artifacts" - uses: actions/download-artifact@v7 - with: - pattern: artifacts-* - path: artifacts - merge-multiple: true - - name: Cleanup - run: | - # Remove internal cargo-dist manifests from the public GitHub Release. - rm -f artifacts/*-dist-manifest.json artifacts/dist-manifest.json - - name: Generate changelog - id: changelog - uses: orhun/git-cliff-action@v4 - with: - args: --latest --strip header - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create GitHub Release - env: - PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}" - ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}" - RELEASE_COMMIT: "${{ github.sha }}" - CHANGELOG: "${{ steps.changelog.outputs.content }}" - RELEASE_TAG: "${{ needs.plan.outputs.tag }}" - APP_VERSION: "${{ fromJson(steps.host.outputs.manifest).releases[0].app_version }}" - run: | - echo "$CHANGELOG" > $RUNNER_TEMP/notes.txt - cat >> $RUNNER_TEMP/notes.txt <> "$GITHUB_OUTPUT" + echo "tag=$tag" >> "$GITHUB_OUTPUT" - custom-publish-aur: - needs: - - plan - - host - if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} - uses: ./.github/workflows/publish-aur.yml - with: - plan: ${{ needs.plan.outputs.val }} - secrets: inherit - # publish jobs get escalated permissions - permissions: - "contents": "read" + if [[ "$release" == true ]]; then + echo "releasing $tag (latest release: ${latest:-none})" + else + echo "Cargo.toml version $version is not newer than latest release v$latest; nothing to release" + fi - custom-publish-winget: - needs: - - plan - - host - if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} - uses: ./.github/workflows/publish-winget.yml - with: - plan: ${{ needs.plan.outputs.val }} - secrets: inherit - # publish jobs get escalated permissions - permissions: - "contents": "write" + - name: create tag + if: steps.version.outputs.release == 'true' + env: + TAG: ${{ steps.version.outputs.tag }} + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git tag --annotate "$TAG" --message "Release $TAG" + git push origin "$TAG" - custom-publish-chocolatey: - needs: - - plan - - host - if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} - uses: ./.github/workflows/publish-chocolatey.yml + publish: + needs: prepare + if: needs.prepare.outputs.release == 'true' + uses: ./.github/workflows/build-release.yml with: - plan: ${{ needs.plan.outputs.val }} + tag: ${{ needs.prepare.outputs.tag }} secrets: inherit - # publish jobs get escalated permissions permissions: - "contents": "read" - - announce: - needs: - - plan - - host - - publish-homebrew-formula - - custom-publish-crates - - custom-publish-aur - - custom-publish-winget - - custom-publish-chocolatey - # use "always() && ..." to allow us to wait for all publish jobs while - # still allowing individual publish jobs to skip themselves (for prereleases). - # "host" however must run to completion, no skipping allowed! - if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.custom-publish-crates.result == 'skipped' || needs.custom-publish-crates.result == 'success') && (needs.custom-publish-aur.result == 'skipped' || needs.custom-publish-aur.result == 'success') && (needs.custom-publish-winget.result == 'skipped' || needs.custom-publish-winget.result == 'success') && (needs.custom-publish-chocolatey.result == 'skipped' || needs.custom-publish-chocolatey.result == 'success') }} - runs-on: "ubuntu-22.04" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v6 - with: - persist-credentials: false - submodules: recursive + contents: write diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml deleted file mode 100644 index 80dcd41..0000000 --- a/.github/workflows/tag-release.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: tag release - -on: - workflow_dispatch: - workflow_run: - workflows: ["build"] - branches: [master] - types: [completed] - -permissions: - contents: read - -concurrency: - group: tag-release - cancel-in-progress: false - -jobs: - tag-release: - if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - fetch-tags: true - ref: ${{ github.event.workflow_run.head_sha || 'master' }} - - - name: decide release tag - id: release - shell: bash - run: | - set -euo pipefail - - version=$(awk ' - $0 == "[package]" { in_package = 1; next } - /^\[/ && in_package { exit } - in_package && $1 == "version" { - gsub(/"/, "", $3) - print $3 - exit - } - ' Cargo.toml) - - if [[ -z "$version" ]]; then - echo "failed to read package version from Cargo.toml" >&2 - exit 1 - fi - - latest=$( - git tag --list \ - | sed -nE 's/^v?([0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?)$/\1/p' \ - | sort -V \ - | tail -n1 - ) - - should_release=false - if [[ -z "$latest" ]]; then - should_release=true - elif [[ "$version" != "$latest" && "$(printf '%s\n%s\n' "$latest" "$version" | sort -V | tail -n1)" == "$version" ]]; then - should_release=true - fi - - tag="v${version}" - echo "version=${version}" >> "$GITHUB_OUTPUT" - echo "latest=${latest}" >> "$GITHUB_OUTPUT" - echo "tag=${tag}" >> "$GITHUB_OUTPUT" - echo "should-release=${should_release}" >> "$GITHUB_OUTPUT" - echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - - if [[ "$should_release" == "true" ]]; then - echo "Cargo.toml version ${version} is newer than latest tag ${latest:-}; creating ${tag}." - else - echo "Cargo.toml version ${version} is not newer than latest tag ${latest}; skipping release." - fi - - - name: create release tag - if: ${{ steps.release.outputs.should-release == 'true' }} - env: - GH_TOKEN: ${{ secrets.RELEASE_TOKEN }} - TAG_NAME: ${{ steps.release.outputs.tag }} - TAG_SHA: ${{ steps.release.outputs.sha }} - shell: bash - run: | - set -euo pipefail - - if [[ -z "${GH_TOKEN}" ]]; then - echo "RELEASE_TOKEN is required so the created tag can trigger the generated release workflow." >&2 - exit 1 - fi - - gh api "repos/${{ github.repository }}/git/refs" \ - -f "ref=refs/tags/${TAG_NAME}" \ - -f "sha=${TAG_SHA}" diff --git a/README.md b/README.md index 3c8f08e..d8fdeaa 100644 --- a/README.md +++ b/README.md @@ -67,18 +67,13 @@ brew install objz/tap/rmcl ### Windows -release builds include a `.zip` archive and an `.msi`. WinGet and Chocolatey -packages are submitted from release CI and become available after review. +release builds include a `.zip` archive and an `.msi`. WinGet packages are +submitted from release CI and become available after review. [![WinGet](https://img.shields.io/badge/winget-Objz.Rmcl-0078D4?style=for-the-badge&logo=windows11)](https://winstall.app/apps/Objz.Rmcl) -[![Chocolatey](https://img.shields.io/chocolatey/v/rmcl?style=for-the-badge&logo=chocolatey)](https://community.chocolatey.org/packages/rmcl) - ```powershell # WinGet winget install Objz.Rmcl - -# Chocolatey -choco install rmcl ``` ### Arch Linux diff --git a/cliff.toml b/cliff.toml index ea3991c..98becde 100644 --- a/cliff.toml +++ b/cliff.toml @@ -11,21 +11,21 @@ repo = "rmcl" # See https://keats.github.io/tera/docs/#introduction body = """ {% if version %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + ## {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }} {% else %}\ - ## [unreleased] + ## unreleased {% endif %}\ {% for group, commits in commits | group_by(attribute="group") %} - ### {{ group | striptags | trim | upper_first }} + ### {{ group | striptags | trim }} {% for commit in commits %} - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ {% if commit.breaking %}[**breaking**] {% endif %}\ - {{ commit.message | upper_first }}\ + {{ commit.message }}\ {% if commit.github.pr_number %} ([#{{ commit.github.pr_number }}](https://github.com/objz/rmcl/pull/{{ commit.github.pr_number }})){% endif %}\ {% endfor %} {% endfor %} {% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %} - ### New Contributors + ### new contributors {% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %} - @{{ contributor.username }} made their first contribution\ {% if contributor.pr_number %} in [#{{ contributor.pr_number }}](https://github.com/objz/rmcl/pull/{{ contributor.pr_number }}){% endif %}\ @@ -68,21 +68,21 @@ protect_breaking_commits = false # Assigns commits to groups. # Optionally sets the commit's scope and can decide to exclude commits from further processing. commit_parsers = [ - { message = "^feat", group = "Features" }, - { message = "^fix", group = "Bug Fixes" }, - { message = "^doc", group = "Documentation" }, - { message = "^perf", group = "Performance" }, - { message = "^refactor", group = "Refactor" }, - { message = "^style", group = "Styling" }, - { message = "^test", group = "Testing" }, + { message = "^feat", group = "features" }, + { message = "^fix", group = "bug fixes" }, + { message = "^doc", group = "documentation" }, + { message = "^perf", group = "performance" }, + { message = "^refactor", group = "refactoring" }, + { message = "^style", group = "styling" }, + { message = "^test", group = "testing" }, { message = "^chore\\(release\\): prepare for", skip = true }, { message = "^chore\\(deps.*\\)", skip = true }, { message = "^chore\\(pr\\)", skip = true }, { message = "^chore\\(pull\\)", skip = true }, - { message = "^chore|^ci", group = "Miscellaneous Tasks" }, - { body = ".*security", group = "Security" }, - { message = "^revert", group = "Revert" }, - { message = ".*", group = "Other" }, + { message = "^chore|^ci", group = "maintenance" }, + { body = ".*security", group = "security" }, + { message = "^revert", group = "reverts" }, + { message = ".*", group = "other changes" }, ] # Exclude commits that are not matched by any commit parser. filter_commits = false diff --git a/dist-workspace.toml b/dist-workspace.toml index cd9c59a..414a8fd 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -16,9 +16,9 @@ targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-da # Path that installers should place binaries in install-path = "CARGO_HOME" # Publish jobs to run in CI -publish-jobs = ["homebrew", "./publish-crates", "./publish-aur", "./publish-winget", "./publish-chocolatey"] +publish-jobs = ["homebrew", "./publish-crates", "./publish-aur", "./publish-winget"] # Custom permissions for publish jobs -github-custom-job-permissions = { publish-crates = { contents = "read" }, publish-aur = { contents = "read" }, publish-winget = { contents = "read" }, publish-chocolatey = { contents = "read" } } +github-custom-job-permissions = { publish-crates = { contents = "read" }, publish-aur = { contents = "read" }, publish-winget = { contents = "read" } } # Extra setup steps for release artifact builders github-build-setup = "../dist-build-setup.yml" # Where to host releases diff --git a/pkg/chocolatey/rmcl.nuspec b/pkg/chocolatey/rmcl.nuspec deleted file mode 100644 index 61d44b0..0000000 --- a/pkg/chocolatey/rmcl.nuspec +++ /dev/null @@ -1,24 +0,0 @@ - - - - rmcl - 0.0.0 - https://github.com/objz/rmcl - objz - rmcl Minecraft Launcher - objz - https://github.com/objz/rmcl - https://github.com/objz/rmcl/blob/master/LICENSE - false - https://github.com/objz/rmcl - https://github.com/objz/rmcl#readme - https://github.com/objz/rmcl/issues - https://github.com/objz/rmcl/releases - minecraft launcher cli tui rust - Minecraft launcher TUI - A fully featured Minecraft launcher TUI with Microsoft account authentication, instance management, mod loaders, imports, content management, and launch support. - - - - - diff --git a/pkg/chocolatey/tools/chocolateyInstall.ps1 b/pkg/chocolatey/tools/chocolateyInstall.ps1 deleted file mode 100644 index 06a5005..0000000 --- a/pkg/chocolatey/tools/chocolateyInstall.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -$ErrorActionPreference = 'Stop' - -$packageArgs = @{ - packageName = $env:ChocolateyPackageName - fileType = 'msi' - url64bit = 'https://github.com/objz/rmcl/releases/download/__TAG__/rmcl-x86_64-pc-windows-msvc.msi' - softwareName = 'rmcl*' - checksum64 = '__CHECKSUM64__' - checksumType64 = 'sha256' - silentArgs = '/quiet /norestart' - validExitCodes = @(0, 3010, 1641) -} - -Install-ChocolateyPackage @packageArgs diff --git a/src/tui/event.rs b/src/tui/event.rs index 6df8130..ba9c470 100644 --- a/src/tui/event.rs +++ b/src/tui/event.rs @@ -69,11 +69,7 @@ impl App { let input_changed = self.handle_events().wrap_err("handle events failed")?; let continuously_animated = progress_active || error_buffer::has_errors(); let safety_refresh = last_draw.elapsed() >= Duration::from_secs(1); - if input_changed - || continuously_animated - || safety_refresh - || redraw_requested - { + if input_changed || continuously_animated || safety_refresh || redraw_requested { terminal.draw(|frame| self.render_frame(frame))?; last_draw = std::time::Instant::now(); } diff --git a/src/tui/widgets/content/list.rs b/src/tui/widgets/content/list.rs index d203dbd..f81e31c 100644 --- a/src/tui/widgets/content/list.rs +++ b/src/tui/widgets/content/list.rs @@ -131,8 +131,7 @@ impl ContentListState { let font_size = picker.font_size(); for entry in &self.entries { - if entry.icon_bytes.is_none() - || !self.requested_images.insert(entry.file_stem.clone()) + if entry.icon_bytes.is_none() || !self.requested_images.insert(entry.file_stem.clone()) { continue; } @@ -194,9 +193,7 @@ impl ContentListState { if let Some(entry) = self .entries .iter_mut() - .find(|entry| { - entry.file_stem == result.file_stem && entry.path == result.path - }) + .find(|entry| entry.file_stem == result.file_stem && entry.path == result.path) { entry.icon_lines = Some(result.icon_lines); if let Some(image) = result.image {