diff --git a/.github/dist-build-setup.yml b/.github/dist-build-setup.yml new file mode 100644 index 0000000..fb05694 --- /dev/null +++ b/.github/dist-build-setup.yml @@ -0,0 +1,5 @@ +- name: install JDK + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: "21" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6736544..80d35ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,213 +7,28 @@ on: branches: [master] permissions: - contents: write + contents: read jobs: - build: - strategy: - matrix: - include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - artifact: mcl - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - artifact: mcl - - os: windows-latest - target: x86_64-pc-windows-msvc - artifact: mcl.exe - - os: macos-latest - target: x86_64-apple-darwin - artifact: mcl - - os: macos-latest - target: aarch64-apple-darwin - artifact: mcl - - runs-on: ${{ matrix.os }} + check: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - name: install Rust uses: dtolnay/rust-toolchain@stable + + - name: install JDK + uses: actions/setup-java@v5 with: - targets: ${{ matrix.target }} + distribution: temurin + java-version: "21" - uses: Swatinem/rust-cache@v2 - with: - key: ${{ matrix.target }} - - name: install cross-compilation deps (aarch64-linux) - if: matrix.target == 'aarch64-unknown-linux-gnu' - run: | - sudo apt-get update - sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + - name: check + run: cargo check --locked - - name: build - env: - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc - run: cargo build --release --target ${{ matrix.target }} - - - name: get version - id: version - shell: bash - run: | - version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') - echo "version=$version" >> "$GITHUB_OUTPUT" - - - name: package (unix) - if: runner.os != 'Windows' - run: | - cd target/${{ matrix.target }}/release - tar czf ../../../mcl-${{ steps.version.outputs.version }}-${{ matrix.target }}.tar.gz ${{ matrix.artifact }} - - - name: package (windows) - if: runner.os == 'Windows' - run: | - cd target/${{ matrix.target }}/release - Compress-Archive -Path ${{ matrix.artifact }} -DestinationPath ../../../mcl-${{ steps.version.outputs.version }}-${{ matrix.target }}.zip - - - name: upload artifact - uses: actions/upload-artifact@v7 - with: - name: mcl-${{ steps.version.outputs.version }}-${{ matrix.target }} - path: mcl-${{ steps.version.outputs.version }}-${{ matrix.target }}.* - - release: - needs: build - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' && github.event_name == 'push' - outputs: - released: ${{ steps.check.outputs.exists == 'false' }} - version: ${{ steps.version.outputs.version }} - tag: ${{ steps.version.outputs.tag }} - - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: get version - id: version - run: | - version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') - echo "version=$version" >> "$GITHUB_OUTPUT" - echo "tag=v$version" >> "$GITHUB_OUTPUT" - - - name: check if release exists - id: check - run: | - if gh release view "${{ steps.version.outputs.tag }}" > /dev/null 2>&1; then - echo "exists=true" >> "$GITHUB_OUTPUT" - else - echo "exists=false" >> "$GITHUB_OUTPUT" - fi - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: download artifacts - if: steps.check.outputs.exists == 'false' - uses: actions/download-artifact@v8 - with: - path: artifacts - - - name: create and push tag - if: steps.check.outputs.exists == 'false' - run: | - git tag "${{ steps.version.outputs.tag }}" - git push origin "${{ steps.version.outputs.tag }}" - - - name: generate changelog - if: steps.check.outputs.exists == 'false' - id: changelog - uses: orhun/git-cliff-action@v4 - with: - args: --latest --strip header - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: create release - if: steps.check.outputs.exists == 'false' - run: | - gh release create "${{ steps.version.outputs.tag }}" \ - --title "${{ steps.version.outputs.tag }}" \ - --notes "${{ steps.changelog.outputs.content }}" \ - artifacts/mcl-*/* - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - publish-crates: - needs: release - runs-on: ubuntu-latest - if: needs.release.outputs.released == 'true' - - steps: - - uses: actions/checkout@v6 - - - name: install Rust - uses: dtolnay/rust-toolchain@stable - - - name: publish to crates.io - run: cargo publish --allow-dirty - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - publish-aur: - needs: release - runs-on: ubuntu-latest - if: needs.release.outputs.released == 'true' - - steps: - - uses: actions/checkout@v6 - - # mcl-launcher (source package) - - name: prepare mcl-launcher - run: | - sed -i "s|^pkgver=.*|pkgver=${{ needs.release.outputs.version }}|" pkg/mcl-launcher/PKGBUILD - cp pkg/mcl-launcher/PKGBUILD PKGBUILD - - - name: update checksums for mcl-launcher - uses: datakrama/archlinux-package-action@v2 - with: - updpkgsums: true - srcinfo: true - flags: "" - namcap: false - - - name: publish mcl-launcher to AUR - uses: KSXGitHub/github-actions-deploy-aur@v4.1.3 - with: - pkgname: mcl-launcher - pkgbuild: PKGBUILD - assets: .SRCINFO - commit_username: objz - commit_email: me@objz.dev - ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} - commit_message: "Update to ${{ needs.release.outputs.version }}" - - # mcl-launcher-bin (binary package) - - name: prepare mcl-launcher-bin - run: | - sed -i "s|^pkgver=.*|pkgver=${{ needs.release.outputs.version }}|" pkg/mcl-launcher-bin/PKGBUILD - cp pkg/mcl-launcher-bin/PKGBUILD PKGBUILD - rm -f .SRCINFO - - - name: update checksums for mcl-launcher-bin - uses: datakrama/archlinux-package-action@v2 - with: - updpkgsums: true - srcinfo: true - flags: "" - namcap: false - - - name: publish mcl-launcher-bin to AUR - uses: KSXGitHub/github-actions-deploy-aur@v4.1.3 - with: - pkgname: mcl-launcher-bin - pkgbuild: PKGBUILD - assets: .SRCINFO - commit_username: objz - commit_email: me@objz.dev - ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} - commit_message: "Update to ${{ needs.release.outputs.version }}" + - name: clippy + run: cargo clippy --all-targets --locked -- -D warnings diff --git a/.github/workflows/publish-aur.yml b/.github/workflows/publish-aur.yml new file mode 100644 index 0000000..5468e52 --- /dev/null +++ b/.github/workflows/publish-aur.yml @@ -0,0 +1,102 @@ +name: publish AUR + +on: + workflow_call: + inputs: + plan: + required: true + type: string + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + env: + PLAN: ${{ inputs.plan }} + + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ fromJson(inputs.plan).announcement_tag }} + + - name: get version + id: version + shell: bash + run: | + version="$(jq --raw-output '.releases[0].app_version' <<< "$PLAN")" + echo "version=$version" >> "$GITHUB_OUTPUT" + + - name: prepare mcl-launcher + run: | + sed -i "s|^pkgver=.*|pkgver=${{ steps.version.outputs.version }}|" pkg/mcl-launcher/PKGBUILD + cp pkg/mcl-launcher/PKGBUILD PKGBUILD + + - name: update checksums for mcl-launcher + uses: datakrama/archlinux-package-action@v2 + with: + updpkgsums: true + srcinfo: true + flags: "" + namcap: false + + - name: publish mcl-launcher to AUR + uses: KSXGitHub/github-actions-deploy-aur@v4.1.3 + with: + pkgname: mcl-launcher + pkgbuild: PKGBUILD + assets: .SRCINFO + commit_username: objz + commit_email: me@objz.dev + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + commit_message: "Update to ${{ steps.version.outputs.version }}" + + - name: prepare mcl-launcher-bin + run: | + sed -i "s|^pkgver=.*|pkgver=${{ steps.version.outputs.version }}|" pkg/mcl-launcher-bin/PKGBUILD + cp pkg/mcl-launcher-bin/PKGBUILD PKGBUILD + rm -f .SRCINFO + + - name: update checksums for mcl-launcher-bin + uses: datakrama/archlinux-package-action@v2 + with: + updpkgsums: true + srcinfo: true + flags: "" + namcap: false + + - name: publish mcl-launcher-bin to AUR + uses: KSXGitHub/github-actions-deploy-aur@v4.1.3 + with: + pkgname: mcl-launcher-bin + pkgbuild: PKGBUILD + assets: .SRCINFO + commit_username: objz + commit_email: me@objz.dev + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + commit_message: "Update to ${{ steps.version.outputs.version }}" + + - name: prepare mcl-launcher-git + run: | + cp pkg/mcl-launcher-git/PKGBUILD PKGBUILD + rm -f .SRCINFO + + - name: update metadata for mcl-launcher-git + uses: datakrama/archlinux-package-action@v2 + with: + updpkgsums: true + srcinfo: true + flags: "" + namcap: false + + - name: publish mcl-launcher-git to AUR + uses: KSXGitHub/github-actions-deploy-aur@v4.1.3 + with: + pkgname: mcl-launcher-git + pkgbuild: PKGBUILD + assets: .SRCINFO + commit_username: objz + commit_email: me@objz.dev + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + commit_message: "Update package metadata" diff --git a/.github/workflows/publish-chocolatey.yml b/.github/workflows/publish-chocolatey.yml new file mode 100644 index 0000000..5454673 --- /dev/null +++ b/.github/workflows/publish-chocolatey.yml @@ -0,0 +1,53 @@ +name: publish Chocolatey + +on: + workflow_call: + inputs: + plan: + required: true + type: string + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + env: + PLAN: ${{ inputs.plan }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ fromJson(inputs.plan).announcement_tag }} + + - name: prepare Chocolatey package + id: package + shell: bash + run: | + tag="$(jq --raw-output '.announcement_tag' <<< "$PLAN")" + version="$(jq --raw-output '.releases[0].app_version' <<< "$PLAN")" + package_dir="target/chocolatey/mcl-launcher" + checksum_file="mcl-launcher-x86_64-pc-windows-msvc.msi.sha256" + + mkdir -p "$package_dir" + cp -R pkg/chocolatey/* "$package_dir/" + gh release download "$tag" --pattern "$checksum_file" --dir "$package_dir" + + checksum="$(awk '{print $1}' "$package_dir/$checksum_file")" + sed -i "s|__TAG__|$tag|g; s|__CHECKSUM64__|$checksum|g" "$package_dir/tools/chocolateyInstall.ps1" + sed -i "s|__TAG__|$tag|g; s|__CHECKSUM64__|$checksum|g" "$package_dir/tools/VERIFICATION.txt" + + echo "version=$version" >> "$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 }}/mcl-launcher.nuspec --version ${{ steps.package.outputs.version }} --output-directory target/chocolatey/out + + - name: push Chocolatey package + uses: crazy-max/ghaction-chocolatey@v4 + with: + args: push target/chocolatey/out/mcl-launcher.${{ steps.package.outputs.version }}.nupkg --source "https://push.chocolatey.org/" --api-key "${{ secrets.CHOCOLATEY_API_KEY }}" diff --git a/.github/workflows/publish-crates.yml b/.github/workflows/publish-crates.yml new file mode 100644 index 0000000..4f6ab0d --- /dev/null +++ b/.github/workflows/publish-crates.yml @@ -0,0 +1,28 @@ +name: publish crates + +on: + workflow_call: + inputs: + plan: + required: true + type: string + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ fromJson(inputs.plan).announcement_tag }} + + - name: install Rust + uses: dtolnay/rust-toolchain@stable + + - name: publish to crates.io + run: cargo publish --allow-dirty + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/publish-winget.yml b/.github/workflows/publish-winget.yml new file mode 100644 index 0000000..115ae16 --- /dev/null +++ b/.github/workflows/publish-winget.yml @@ -0,0 +1,99 @@ +name: publish WinGet + +on: + workflow_call: + inputs: + plan: + required: true + type: string + +permissions: + contents: read + +jobs: + publish: + runs-on: windows-latest + + steps: + - name: prepare WinGet manifest + id: manifest + shell: pwsh + env: + PLAN: ${{ inputs.plan }} + run: | + $plan = $env:PLAN | ConvertFrom-Json + $tag = $plan.announcement_tag + $version = $plan.releases[0].app_version + $identifier = 'Objz.MclLauncher' + $packagePath = "manifests/o/Objz/MclLauncher/$version" + $installerFile = 'mcl-launcher-x86_64-pc-windows-msvc.msi' + $checksumFile = "$installerFile.sha256" + $installerUrl = "https://github.com/objz/mcl/releases/download/$tag/$installerFile" + $checksumUrl = "https://github.com/objz/mcl/releases/download/$tag/$checksumFile" + + New-Item -ItemType Directory -Path $packagePath -Force | Out-Null + Invoke-WebRequest -Uri $checksumUrl -OutFile "$packagePath/$checksumFile" + $checksum = (((Get-Content "$packagePath/$checksumFile" -Raw) -split '\s+')[0]).ToUpperInvariant() + + $versionManifest = @" + PackageIdentifier: $identifier + PackageVersion: $version + DefaultLocale: en-US + ManifestType: version + ManifestVersion: 1.9.0 + "@ + $versionManifest | Set-Content -Path "$packagePath/$identifier.yaml" -Encoding utf8 + + $installerManifest = @" + PackageIdentifier: $identifier + PackageVersion: $version + InstallerType: wix + Scope: machine + InstallerSwitches: + Silent: /quiet /norestart + SilentWithProgress: /passive /norestart + UpgradeBehavior: install + Commands: + - mcl + Installers: + - Architecture: x64 + InstallerUrl: $installerUrl + InstallerSha256: $checksum + ManifestType: installer + ManifestVersion: 1.9.0 + "@ + $installerManifest | Set-Content -Path "$packagePath/$identifier.installer.yaml" -Encoding utf8 + + $localeManifest = @" + PackageIdentifier: $identifier + PackageVersion: $version + PackageLocale: en-US + Publisher: objz + PublisherUrl: https://github.com/objz + PublisherSupportUrl: https://github.com/objz/mcl/issues + Author: objz + PackageName: mcl-launcher + PackageUrl: https://github.com/objz/mcl + License: GPL-3.0-only + LicenseUrl: https://github.com/objz/mcl/blob/master/LICENSE + Copyright: Copyright (c) objz + ShortDescription: Minecraft launcher TUI + Description: A fully featured Minecraft launcher TUI with Microsoft account authentication, instance management, mod loaders, imports, content management, and launch support. + Moniker: mcl + Tags: + - minecraft + - launcher + - cli + - tui + ManifestType: defaultLocale + ManifestVersion: 1.9.0 + "@ + $localeManifest | Set-Content -Path "$packagePath/$identifier.locale.en-US.yaml" -Encoding utf8 + + "path=$packagePath" >> $env:GITHUB_OUTPUT + + - name: submit WinGet manifest + shell: pwsh + run: | + Invoke-WebRequest -Uri https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe + .\wingetcreate.exe submit "${{ steps.manifest.outputs.path }}" --token "${{ secrets.WINGET_TOKEN }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..36484e2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,404 @@ +# 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: + push: + tags: + - '**[0-9]+.[0-9]+.[0-9]+*' + +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: ${{ !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 }} + 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 }} + 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 + - 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 the granular manifests + rm -f artifacts/*-dist-manifest.json + - 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 }}" + ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}" + RELEASE_COMMIT: "${{ github.sha }}" + run: | + # Write and read notes from a file to avoid quoting breaking things + echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt + + gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/* + + publish-homebrew-formula: + needs: + - plan + - host + runs-on: "ubuntu-22.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PLAN: ${{ needs.plan.outputs.val }} + GITHUB_USER: "axo bot" + GITHUB_EMAIL: "admin+bot@axo.dev" + if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: true + repository: "objz/homebrew-tap" + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} + # So we have access to the formula + - name: Fetch homebrew formulae + uses: actions/download-artifact@v7 + with: + pattern: artifacts-* + path: Formula/ + merge-multiple: true + # This is extra complex because you can make your Formula name not match your app name + # so we need to find releases with a *.rb file, and publish with that filename. + - name: Commit formula files + run: | + git config --global user.name "${GITHUB_USER}" + git config --global user.email "${GITHUB_EMAIL}" + + for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do + filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output) + name=$(echo "$filename" | sed "s/\.rb$//") + version=$(echo "$release" | jq .app_version --raw-output) + + export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH" + brew update + # We avoid reformatting user-provided data such as the app description and homepage. + brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true + + git add "Formula/${filename}" + git commit -m "${name} ${version}" + done + git push + + custom-publish-crates: + needs: + - plan + - host + if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} + uses: ./.github/workflows/publish-crates.yml + with: + plan: ${{ needs.plan.outputs.val }} + secrets: inherit + # publish jobs get escalated permissions + permissions: + "contents": "read" + + 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" + + 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": "read" + + 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 + with: + plan: ${{ needs.plan.outputs.val }} + 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 diff --git a/Cargo.lock b/Cargo.lock index a9af0a4..6a24786 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1879,7 +1879,7 @@ dependencies = [ [[package]] name = "mcl-launcher" -version = "0.2.2" +version = "0.2.3" dependencies = [ "async-trait", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 2ca055e..a33e4f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,22 @@ [package] name = "mcl-launcher" -version = "0.2.2" +version = "0.2.3" authors = ["objz"] edition = "2024" description = "A fully featured Minecraft launcher TUI" repository = "https://github.com/objz/mcl" +homepage = "https://github.com/objz/mcl" license = "GPL-3.0-only" readme = "README.md" keywords = ["minecraft", "launcher", "tui", "ratatui"] categories = ["command-line-utilities", "games"] +[package.metadata.wix] +upgrade-guid = "BEC08BE4-6A8F-4C1D-A1B4-B1AC963000AE" +path-guid = "E5863AC2-13FC-45C8-B79D-55338F371A8A" +license = false +eula = false + [[bin]] name = "mcl" path = "src/main.rs" @@ -59,5 +66,10 @@ lto = true opt-level = "s" strip = true +# The profile that 'dist' will build with +[profile.dist] +inherits = "release" +lto = "thin" + [dev-dependencies] tempfile = "3" diff --git a/README.md b/README.md index a0e5f93..d025a16 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,36 @@ Authentication is performed through Microsoft’s official services. ## installation +### macOS / Linux + +release builds include shell and Homebrew installers generated by +[`cargo-dist`](https://axodotdev.github.io/cargo-dist/). + +```sh +# installer script +curl --proto '=https' --tlsv1.2 -LsSf https://github.com/objz/mcl/releases/latest/download/mcl-launcher-installer.sh | sh + +# Homebrew tap +brew install objz/tap/mcl-launcher +``` + +### Windows + +release builds include a PowerShell installer and an MSI. WinGet and Chocolatey +packages are submitted from release CI and become available after repository +review. + +```powershell +# installer script +powershell -ExecutionPolicy Bypass -c "irm https://github.com/objz/mcl/releases/latest/download/mcl-launcher-installer.ps1 | iex" + +# WinGet +winget install Objz.MclLauncher + +# Chocolatey +choco install mcl-launcher +``` + ### Arch Linux [![AUR version](https://img.shields.io/aur/version/mcl-launcher?style=for-the-badge&label=mcl-launcher)](https://aur.archlinux.org/packages/mcl-launcher) @@ -69,7 +99,7 @@ also available on [crates.io](https://crates.io/crates/mcl-launcher) ### from source -requires a Rust toolchain. +requires a Rust toolchain and a JDK (`javac` and `jar` on `PATH`). ```sh git clone https://github.com/objz/mcl.git @@ -77,10 +107,6 @@ cd mcl cargo build --release ``` -### other platforms - -mcl can be compiled for Linux, macOS, and Windows. right now it's only packaged for Arch Linux (AUR) but official packages for other platforms and package managers will be added continuously. - --- ## where things live diff --git a/dist-workspace.toml b/dist-workspace.toml new file mode 100644 index 0000000..38b4d54 --- /dev/null +++ b/dist-workspace.toml @@ -0,0 +1,27 @@ +[workspace] +members = ["cargo:."] + +# Config for 'dist' +[dist] +# The preferred dist version to use in CI (Cargo.toml SemVer syntax) +cargo-dist-version = "0.31.0" +# CI backends to support +ci = "github" +# The installers to generate for each app +installers = ["shell", "powershell", "homebrew", "msi"] +# A GitHub repo to push Homebrew formulas to +tap = "objz/homebrew-tap" +# Target platforms to build apps for (Rust target-triple syntax) +targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"] +# 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"] +# 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" } } +# Extra setup steps for release artifact builders +github-build-setup = "../dist-build-setup.yml" +# Where to host releases +hosting = "github" +# Whether to install an updater program +install-updater = false diff --git a/pkg/chocolatey/mcl-launcher.nuspec b/pkg/chocolatey/mcl-launcher.nuspec new file mode 100644 index 0000000..527fafb --- /dev/null +++ b/pkg/chocolatey/mcl-launcher.nuspec @@ -0,0 +1,23 @@ + + + + mcl-launcher + 0.0.0 + https://github.com/objz/mcl + objz + mcl-launcher + objz + https://github.com/objz/mcl + https://github.com/objz/mcl/blob/master/LICENSE + false + https://github.com/objz/mcl + https://github.com/objz/mcl#readme + https://github.com/objz/mcl/issues + 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/VERIFICATION.txt b/pkg/chocolatey/tools/VERIFICATION.txt new file mode 100644 index 0000000..2d6d420 --- /dev/null +++ b/pkg/chocolatey/tools/VERIFICATION.txt @@ -0,0 +1,12 @@ +VERIFICATION + +This package downloads the official MSI from the GitHub release: + +https://github.com/objz/mcl/releases/download/__TAG__/mcl-launcher-x86_64-pc-windows-msvc.msi + +The SHA256 checksum is generated by cargo-dist and published next to the release asset: + +https://github.com/objz/mcl/releases/download/__TAG__/mcl-launcher-x86_64-pc-windows-msvc.msi.sha256 + +Expected SHA256: +__CHECKSUM64__ diff --git a/pkg/chocolatey/tools/chocolateyInstall.ps1 b/pkg/chocolatey/tools/chocolateyInstall.ps1 new file mode 100644 index 0000000..c560328 --- /dev/null +++ b/pkg/chocolatey/tools/chocolateyInstall.ps1 @@ -0,0 +1,14 @@ +$ErrorActionPreference = 'Stop' + +$packageArgs = @{ + packageName = $env:ChocolateyPackageName + fileType = 'msi' + url64bit = 'https://github.com/objz/mcl/releases/download/__TAG__/mcl-launcher-x86_64-pc-windows-msvc.msi' + softwareName = 'mcl-launcher*' + checksum64 = '__CHECKSUM64__' + checksumType64 = 'sha256' + silentArgs = '/quiet /norestart' + validExitCodes = @(0, 3010, 1641) +} + +Install-ChocolateyPackage @packageArgs diff --git a/pkg/mcl-launcher-bin/PKGBUILD b/pkg/mcl-launcher-bin/PKGBUILD index f662452..2d927b6 100644 --- a/pkg/mcl-launcher-bin/PKGBUILD +++ b/pkg/mcl-launcher-bin/PKGBUILD @@ -10,8 +10,8 @@ depends=() provides=('mcl-launcher') conflicts=('mcl-launcher' 'mcl-launcher-git') source=("LICENSE-${pkgver}::${url}/raw/v${pkgver}/LICENSE" "README-${pkgver}::${url}/raw/v${pkgver}/README.md") -source_x86_64=("${url}/releases/download/v${pkgver}/mcl-${pkgver}-x86_64-unknown-linux-gnu.tar.gz") -source_aarch64=("${url}/releases/download/v${pkgver}/mcl-${pkgver}-aarch64-unknown-linux-gnu.tar.gz") +source_x86_64=("${url}/releases/download/v${pkgver}/mcl-launcher-x86_64-unknown-linux-gnu.tar.xz") +source_aarch64=("${url}/releases/download/v${pkgver}/mcl-launcher-aarch64-unknown-linux-gnu.tar.xz") sha256sums=('SKIP' 'SKIP') sha256sums_x86_64=('SKIP') sha256sums_aarch64=('SKIP') diff --git a/pkg/mcl-launcher-git/PKGBUILD b/pkg/mcl-launcher-git/PKGBUILD index 1ffd093..115936d 100644 --- a/pkg/mcl-launcher-git/PKGBUILD +++ b/pkg/mcl-launcher-git/PKGBUILD @@ -7,7 +7,7 @@ arch=('x86_64' 'aarch64') url="https://github.com/objz/mcl" license=('GPL-3.0-only') depends=() -makedepends=('git' 'rust' 'cargo') +makedepends=('git' 'rust' 'cargo' 'jdk-openjdk') provides=('mcl-launcher') conflicts=('mcl-launcher' 'mcl-launcher-bin') source=("git+$url.git") diff --git a/pkg/mcl-launcher/PKGBUILD b/pkg/mcl-launcher/PKGBUILD index a6b7f20..5777416 100644 --- a/pkg/mcl-launcher/PKGBUILD +++ b/pkg/mcl-launcher/PKGBUILD @@ -7,7 +7,7 @@ arch=('x86_64' 'aarch64') url="https://github.com/objz/mcl" license=('GPL-3.0-only') depends=() -makedepends=('rust' 'cargo') +makedepends=('rust' 'cargo' 'jdk-openjdk') provides=('mcl-launcher') conflicts=('mcl-launcher-bin' 'mcl-launcher-git') source=("${url}/archive/v${pkgver}.tar.gz") diff --git a/wix/main.wxs b/wix/main.wxs new file mode 100644 index 0000000..1fca2ad --- /dev/null +++ b/wix/main.wxs @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + +