15 Commits
Author SHA1 Message Date
objz de6af2de18 ci: fixed aur checksums and chocolatey workflow 2026-04-27 13:17:41 +02:00
objz ff7bb55faa ci: fixed duplicate runs 2026-04-27 12:54:27 +02:00
objz 495a4b3fa1 ci: fixed chocolatey workflow and hombrew 2026-04-27 12:51:29 +02:00
objz 3d8b3deb74 ci: fixed aur checksums and workflows 2026-04-27 12:32:31 +02:00
objz ec378b0b59 fix: trigger release workflow via dispatch after creating tag
API-created tags don't emit push events, so the release workflow
never started. Now tag-release explicitly dispatches the release
workflow after creating the tag.
2026-04-26 22:10:44 +02:00
objz a0a03a8f8f fix: tag-release re-tags when existing tag points to wrong commit
Previously if a tag already existed (e.g. from a failed release),
tag-release would skip because the version matched the latest tag.
Now it detects stale tags pointing to the wrong SHA and re-creates them.
2026-04-26 22:09:01 +02:00
objz 2acbec94c9 ci: fixexed tag release failing 2026-04-26 22:06:43 +02:00
objz ec016293cb Merge branch 'master' of https://github.com/objz/mcl 2026-04-26 22:03:28 +02:00
objz b4b1b0ffca fix: release workflow fixes and version bump to 0.2.4
- Fix AUR mcl-launcher-bin package path for dist tarballs
- Fix WinGet manifest validation by removing leftover sha256 file
- Use RELEASE_TOKEN for homebrew tap access
- Restore git-cliff changelog in GitHub releases
- Remove shell/powershell installer scripts from dist config
2026-04-26 22:02:23 +02:00
objz 0a7f9282cc fix: release workflow fixes and version bump to 0.2.4
- Fix AUR mcl-launcher-bin package path for dist tarballs
- Fix WinGet manifest validation by removing leftover sha256 file
- Use RELEASE_TOKEN for homebrew tap access
- Restore git-cliff changelog in GitHub releases
- Remove shell/powershell installer scripts from dist config
2026-04-26 21:59:59 +02:00
objz 6d6e67bbba ci: fixexed tag release 2026-04-26 21:38:31 +02:00
objz 1a6c6ad9f5 ci: fixed releases wont get the right tag 2026-04-26 21:34:26 +02:00
objz 1feb1679ff fix: clippy errors 2026-04-26 21:27:14 +02:00
objz 441607f0da ci: add release packaging 2026-04-26 21:22:01 +02:00
objz 33b2d856bc feat: require verified account for offline play 2026-04-26 20:37:52 +02:00
27 changed files with 1602 additions and 310 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
- name: install JDK
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
+14 -197
View File
@@ -7,30 +7,11 @@ 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
@@ -38,182 +19,18 @@ jobs:
- name: install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: clippy
- name: install JDK
uses: actions/setup-java@v5
with:
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
+103
View File
@@ -0,0 +1,103 @@
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
sed -i "s|^pkgrel=.*|pkgrel=1|" 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"
+98
View File
@@ -0,0 +1,98 @@
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 }}
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ fromJson(inputs.plan).announcement_tag }}
- name: verify Chocolatey publishing secret
shell: bash
run: |
if [ -z "${CHOCOLATEY_API_KEY}" ]; then
echo "::error::CHOCOLATEY_API_KEY is required to publish mcl-launcher to Chocolatey."
exit 1
fi
- 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
shell: bash
run: |
package="target/chocolatey/out/mcl-launcher.${{ steps.package.outputs.version }}.nupkg"
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
echo "::error::Chocolatey rejected the push with 403 before any server-side failure. Check CHOCOLATEY_API_KEY ownership/permissions for mcl-launcher."
exit 1
fi
if [ "$attempt" -eq 3 ]; then
break
fi
sleep $((attempt * 30))
done
exit 1
+46
View File
@@ -0,0 +1,46 @@
name: publish crates
on:
workflow_dispatch:
inputs:
plan:
required: true
type: string
dry_run:
required: false
type: boolean
default: true
workflow_call:
inputs:
plan:
required: true
type: string
dry_run:
required: false
type: boolean
default: false
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: |
if [ "${{ inputs.dry_run }}" = "true" ]; then
cargo publish --allow-dirty --dry-run
else
cargo publish --allow-dirty
fi
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
+104
View File
@@ -0,0 +1,104 @@
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 = @(
'# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.9.0.schema.json'
"PackageIdentifier: $identifier"
"PackageVersion: $version"
'DefaultLocale: en-US'
'ManifestType: version'
'ManifestVersion: 1.9.0'
) -join "`n"
$versionManifest | Set-Content -Path "$packagePath/$identifier.yaml" -Encoding utf8
$installerManifest = @(
'# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.9.0.schema.json'
"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'
) -join "`n"
$installerManifest | Set-Content -Path "$packagePath/$identifier.installer.yaml" -Encoding utf8
$localeManifest = @(
'# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.9.0.schema.json'
"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'
) -join "`n"
$localeManifest | Set-Content -Path "$packagePath/$identifier.locale.en-US.yaml" -Encoding utf8
Remove-Item "$packagePath/$checksumFile"
"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 }}"
+469
View File
@@ -0,0 +1,469 @@
# 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]+*'
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":{"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<<EOF" >> "$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<<EOF" >> "$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
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: "${{ github.sha }}"
CHANGELOG: "${{ steps.changelog.outputs.content }}"
RELEASE_TAG: "${{ needs.plan.outputs.tag }}"
run: |
echo "$CHANGELOG" > $RUNNER_TEMP/notes.txt
cat >> $RUNNER_TEMP/notes.txt <<EOF
## Downloads
| File | Platform | Checksum |
| --- | --- | --- |
| [mcl-launcher-aarch64-apple-darwin.tar.xz](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-aarch64-apple-darwin.tar.xz.sha256) |
| [mcl-launcher-x86_64-apple-darwin.tar.xz](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-x86_64-apple-darwin.tar.xz.sha256) |
| [mcl-launcher-x86_64-pc-windows-msvc.zip](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-x86_64-pc-windows-msvc.zip.sha256) |
| [mcl-launcher-x86_64-pc-windows-msvc.msi](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-x86_64-pc-windows-msvc.msi) | x64 Windows | [checksum](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-x86_64-pc-windows-msvc.msi.sha256) |
| [mcl-launcher-aarch64-unknown-linux-gnu.tar.xz](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-aarch64-unknown-linux-gnu.tar.xz) | ARM64 Linux | [checksum](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-aarch64-unknown-linux-gnu.tar.xz.sha256) |
| [mcl-launcher-x86_64-unknown-linux-gnu.tar.xz](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-x86_64-unknown-linux-gnu.tar.xz) | x64 Linux | [checksum](https://github.com/objz/mcl/releases/download/${RELEASE_TAG}/mcl-launcher-x86_64-unknown-linux-gnu.tar.xz.sha256) |
## Cargo
\`\`\`
cargo install mcl-launcher
\`\`\`
## Homebrew
\`\`\`
brew install objz/tap/mcl-launcher
\`\`\`
## WinGet
\`\`\`
winget install Objz.MclLauncher
\`\`\`
## Chocolatey
\`\`\`
choco install mcl-launcher
\`\`\`
## AUR
\`\`\`
paru -S mcl-launcher-bin
\`\`\`
EOF
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 }}
HOMEBREW_TAP_REPOSITORY: "objz/homebrew-tap"
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: ${{ env.HOMEBREW_TAP_REPOSITORY }}
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}"
starting_commit="$(git rev-parse HEAD)"
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}"
if git diff --cached --quiet; then
echo "Formula/${filename} is unchanged"
else
git commit -m "${name} ${version}"
fi
done
if [ "$(git rev-parse HEAD)" = "$starting_commit" ]; then
echo "No Homebrew formula changes to push"
else
git push
fi
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 }}
dry_run: false
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
+94
View File
@@ -0,0 +1,94 @@
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:-<none>}; 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}"
Generated
+124 -48
View File
@@ -19,13 +19,13 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aes"
version = "0.8.4"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
checksum = "66bd29a732b644c0431c6140f370d097879203d79b80c94a6747ba0872adaef8"
dependencies = [
"cfg-if",
"cipher",
"cpufeatures",
"cpubits",
"cpufeatures 0.3.0",
]
[[package]]
@@ -234,6 +234,16 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block-buffer"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be"
dependencies = [
"hybrid-array",
"zeroize",
]
[[package]]
name = "bon"
version = "3.9.1"
@@ -323,9 +333,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.2.60"
version = "1.2.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20"
checksum = "d16d90359e986641506914ba71350897565610e87ce0ad9e6f28569db3dd5c6d"
dependencies = [
"find-msvc-tools",
"jobserver",
@@ -361,11 +371,11 @@ dependencies = [
[[package]]
name = "cipher"
version = "0.4.4"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
checksum = "e34d8227fe1ba289043aeb13792056ff80fd6de1a9f49137a5f499de8e8c78ea"
dependencies = [
"crypto-common",
"crypto-common 0.2.1",
"inout",
]
@@ -396,6 +406,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
[[package]]
name = "cmov"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f88a43d011fc4a6876cb7344703e297c71dda42494fee094d5f7c76bf13f746"
[[package]]
name = "color-eyre"
version = "0.6.5"
@@ -464,6 +480,12 @@ dependencies = [
"yaml-rust2",
]
[[package]]
name = "const-oid"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
[[package]]
name = "const-random"
version = "0.1.18"
@@ -514,6 +536,12 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "cpubits"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ef0c543070d296ea414df2dd7625d1b24866ce206709d8a4a424f28377f5861"
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -523,6 +551,15 @@ dependencies = [
"libc",
]
[[package]]
name = "cpufeatures"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
dependencies = [
"libc",
]
[[package]]
name = "crc32fast"
version = "1.5.0"
@@ -627,6 +664,15 @@ dependencies = [
"typenum",
]
[[package]]
name = "crypto-common"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77727bb15fa921304124b128af125e7e3b968275d1b108b379190264f4423710"
dependencies = [
"hybrid-array",
]
[[package]]
name = "csscolorparser"
version = "0.6.2"
@@ -637,6 +683,15 @@ dependencies = [
"phf",
]
[[package]]
name = "ctutils"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
dependencies = [
"cmov",
]
[[package]]
name = "darling"
version = "0.21.3"
@@ -778,9 +833,21 @@ version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
"subtle",
"block-buffer 0.10.4",
"crypto-common 0.1.7",
]
[[package]]
name = "digest"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c"
dependencies = [
"block-buffer 0.12.0",
"const-oid",
"crypto-common 0.2.1",
"ctutils",
"zeroize",
]
[[package]]
@@ -1223,11 +1290,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hmac"
version = "0.12.1"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"
dependencies = [
"digest",
"digest 0.11.2",
]
[[package]]
@@ -1269,6 +1336,15 @@ version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
[[package]]
name = "hybrid-array"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d46837a0ed51fe95bd3b05de33cd64a1ee88fc797477ca48446872504507c5"
dependencies = [
"typenum",
]
[[package]]
name = "hyper"
version = "1.9.0"
@@ -1539,11 +1615,11 @@ dependencies = [
[[package]]
name = "inout"
version = "0.1.4"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
dependencies = [
"generic-array",
"hybrid-array",
]
[[package]]
@@ -1617,9 +1693,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "jiff"
version = "0.2.23"
version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a3546dc96b6d42c5f24902af9e2538e82e39ad350b0c766eb3fbf2d8f3d8359"
checksum = "f00b5dbd620d61dfdcb6007c9c1f6054ebd75319f163d886a9055cec1155073d"
dependencies = [
"jiff-static",
"jiff-tzdb-platform",
@@ -1632,9 +1708,9 @@ dependencies = [
[[package]]
name = "jiff-static"
version = "0.2.23"
version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a8c8b344124222efd714b73bb41f8b5120b27a7cc1c75593a6ff768d9d05aa4"
checksum = "e000de030ff8022ea1da3f466fbb0f3a809f5e51ed31f6dd931c35181ad8e6d7"
dependencies = [
"proc-macro2",
"quote",
@@ -1767,9 +1843,9 @@ checksum = "b3a6a8c165077efc8f3a971534c50ea6a1a18b329ef4a66e897a7e3a1494565f"
[[package]]
name = "libc"
version = "0.2.185"
version = "0.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
[[package]]
name = "libm"
@@ -1879,7 +1955,7 @@ dependencies = [
[[package]]
name = "mcl-launcher"
version = "0.2.2"
version = "0.2.4"
dependencies = [
"async-trait",
"chrono",
@@ -2166,9 +2242,9 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "open"
version = "5.3.3"
version = "5.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43bb73a7fa3799b198970490a51174027ba0d4ec504b03cd08caf513d40024bc"
checksum = "9f3bab717c29a857abf75fcef718d441ec7cb2725f937343c734740a985d37fd"
dependencies = [
"is-wsl",
"libc",
@@ -2276,11 +2352,11 @@ checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
[[package]]
name = "pbkdf2"
version = "0.12.2"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
checksum = "112d82ceb8c5bf524d9af484d4e4970c9fd5a0cc15ba14ad93dccd28873b0629"
dependencies = [
"digest",
"digest 0.11.2",
"hmac",
]
@@ -3040,9 +3116,9 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.23.38"
version = "0.23.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69f9466fb2c14ea04357e91413efb882e2a6d4a406e625449bc0a5d360d53a21"
checksum = "7c2c118cb077cca2822033836dfb1b975355dfb784b5e8da48f7b6c5db74e60e"
dependencies = [
"once_cell",
"ring",
@@ -3054,9 +3130,9 @@ dependencies = [
[[package]]
name = "rustls-pki-types"
version = "1.14.0"
version = "1.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd"
checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9"
dependencies = [
"web-time",
"zeroize",
@@ -3064,9 +3140,9 @@ dependencies = [
[[package]]
name = "rustls-webpki"
version = "0.103.12"
version = "0.103.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8279bb85272c9f10811ae6a6c547ff594d6a7f3c6c6b02ee9726d1d0dcfcdd06"
checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e"
dependencies = [
"ring",
"rustls-pki-types",
@@ -3204,13 +3280,13 @@ dependencies = [
[[package]]
name = "sha1"
version = "0.10.6"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
"cpufeatures 0.3.0",
"digest 0.11.2",
]
[[package]]
@@ -3220,8 +3296,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
"cpufeatures 0.2.17",
"digest 0.10.7",
]
[[package]]
@@ -3936,9 +4012,9 @@ checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c"
[[package]]
name = "typenum"
version = "1.19.0"
version = "1.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de"
[[package]]
name = "ucd-trie"
@@ -4646,9 +4722,9 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
[[package]]
name = "winnow"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09dac053f1cd375980747450bfc7250c264eaae0583872e845c0c7cd578872b5"
checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0"
dependencies = [
"memchr",
]
@@ -4878,9 +4954,9 @@ dependencies = [
[[package]]
name = "zip"
version = "8.5.1"
version = "8.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcab981e19633ebcf0b001ddd37dd802996098bc1864f90b7c5d970ce76c1d59"
checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b"
dependencies = [
"aes",
"bzip2",
+13 -1
View File
@@ -1,15 +1,22 @@
[package]
name = "mcl-launcher"
version = "0.2.2"
version = "0.2.4"
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"
+31 -5
View File
@@ -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
+29
View File
@@ -0,0 +1,29 @@
[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 = ["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
# Allow custom edits to the generated CI file
allow-dirty = ["ci"]
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>mcl-launcher</id>
<version>0.0.0</version>
<packageSourceUrl>https://github.com/objz/mcl</packageSourceUrl>
<owners>objz</owners>
<title>mcl-launcher</title>
<authors>objz</authors>
<projectUrl>https://github.com/objz/mcl</projectUrl>
<licenseUrl>https://github.com/objz/mcl/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/objz/mcl</projectSourceUrl>
<docsUrl>https://github.com/objz/mcl#readme</docsUrl>
<bugTrackerUrl>https://github.com/objz/mcl/issues</bugTrackerUrl>
<tags>minecraft launcher cli tui rust</tags>
<summary>Minecraft launcher TUI</summary>
<description>A fully featured Minecraft launcher TUI with Microsoft account authentication, instance management, mod loaders, imports, content management, and launch support.</description>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
+12
View File
@@ -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__
@@ -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
+5 -4
View File
@@ -1,7 +1,7 @@
# Maintainer: objz <me@objz.dev>
pkgname=mcl-launcher-bin
pkgver=0.2.0
pkgrel=1
pkgrel=2
pkgdesc="Minecraft launcher TUI"
arch=('x86_64' 'aarch64')
url="https://github.com/objz/mcl"
@@ -10,14 +10,15 @@ 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=("mcl-launcher-${pkgver}-x86_64-unknown-linux-gnu.tar.xz::${url}/releases/download/v${pkgver}/mcl-launcher-x86_64-unknown-linux-gnu.tar.xz")
source_aarch64=("mcl-launcher-${pkgver}-aarch64-unknown-linux-gnu.tar.xz::${url}/releases/download/v${pkgver}/mcl-launcher-aarch64-unknown-linux-gnu.tar.xz")
sha256sums=('SKIP' 'SKIP')
sha256sums_x86_64=('SKIP')
sha256sums_aarch64=('SKIP')
package() {
install -Dm755 mcl "$pkgdir/usr/bin/mcl"
local _dir="mcl-launcher-${CARCH}-unknown-linux-gnu"
install -Dm755 "$_dir/mcl" "$pkgdir/usr/bin/mcl"
install -Dm644 "LICENSE-${pkgver}" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm644 "README-${pkgver}" "$pkgdir/usr/share/doc/$pkgname/README.md"
}
+1 -1
View File
@@ -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")
+1 -1
View File
@@ -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")
+29
View File
@@ -66,6 +66,12 @@ impl AccountStore {
self.accounts.iter().find(|a| a.active)
}
pub fn has_microsoft_account(&self) -> bool {
self.accounts
.iter()
.any(|account| account.account_type == AccountType::Microsoft)
}
pub fn set_active(&mut self, index: usize) {
for (i, acc) in self.accounts.iter_mut().enumerate() {
acc.active = i == index;
@@ -194,6 +200,18 @@ mod tests {
create_offline_account(name)
}
fn microsoft_account(name: &str) -> Account {
Account {
uuid: format!("00000000-0000-0000-0000-{:012}", name.len()),
username: name.to_owned(),
account_type: AccountType::Microsoft,
active: false,
refresh_token: Some("refresh".to_owned()),
cached_mc_token: None,
cached_mc_token_expires_at: None,
}
}
#[test]
fn store_add_first_becomes_active() {
let tmp = tempfile::tempdir().unwrap();
@@ -234,6 +252,17 @@ mod tests {
assert!(store.active_account().is_none());
}
#[test]
fn store_has_microsoft_account_when_one_exists() {
let tmp = tempfile::tempdir().unwrap();
let mut store = make_store(tmp.path());
store.add(dummy_account("Offline"));
assert!(!store.has_microsoft_account());
store.add(microsoft_account("Owner"));
assert!(store.has_microsoft_account());
}
#[test]
fn store_active_account_returns_active() {
let tmp = tempfile::tempdir().unwrap();
+42 -11
View File
@@ -21,13 +21,13 @@ pub async fn handle_account(matches: &ArgMatches) -> CliResult {
// trait indirection so a mock store can be swapped in for tests
trait AccountStoreLike {
fn accounts(&self) -> &[Account];
fn has_microsoft_account(&self) -> bool;
fn add_account(&mut self, account: Account);
}
impl AccountStoreLike for AccountStore {
fn accounts(&self) -> &[Account] {
&self.accounts
fn has_microsoft_account(&self) -> bool {
AccountStore::has_microsoft_account(self)
}
fn add_account(&mut self, account: Account) {
@@ -114,6 +114,12 @@ fn add_offline_account<T: AccountStoreLike>(store: &mut T, username: &str) -> Cl
if username.is_empty() {
return Err(io::Error::other("offline username cannot be empty").into());
}
if !store.has_microsoft_account() {
return Err(io::Error::other(
"add a Microsoft account that owns Minecraft before adding offline accounts",
)
.into());
}
store.add_account(crate::auth::create_offline_account(username));
Ok(())
@@ -122,7 +128,7 @@ fn add_offline_account<T: AccountStoreLike>(store: &mut T, username: &str) -> Cl
fn delete_account(matches: &ArgMatches) -> CliResult {
let username = required_arg(matches, "username")?;
let mut store = AccountStore::load();
let index = find_account_index(store.accounts(), username)
let index = find_account_index(&store.accounts, username)
.ok_or_else(|| io::Error::other(format!("account '{}' not found", username)))?;
if !matches.get_flag("yes") && !confirm(&format!("Delete '{}'", username))? {
@@ -138,7 +144,7 @@ fn delete_account(matches: &ArgMatches) -> CliResult {
fn use_account(matches: &ArgMatches) -> CliResult {
let username = required_arg(matches, "username")?;
let mut store = AccountStore::load();
let index = find_account_index(store.accounts(), username)
let index = find_account_index(&store.accounts, username)
.ok_or_else(|| io::Error::other(format!("account '{}' not found", username)))?;
store.set_active(index);
println!("Active account set to '{}'.", username);
@@ -164,8 +170,10 @@ mod tests {
}
impl AccountStoreLike for MockStore {
fn accounts(&self) -> &[Account] {
&self.accounts
fn has_microsoft_account(&self) -> bool {
self.accounts
.iter()
.any(|account| account.account_type == AccountType::Microsoft)
}
fn add_account(&mut self, account: Account) {
@@ -173,14 +181,37 @@ mod tests {
}
}
fn microsoft_account() -> Account {
Account {
uuid: "00000000-0000-0000-0000-000000000001".to_owned(),
username: "Owner".to_owned(),
account_type: AccountType::Microsoft,
active: false,
refresh_token: Some("refresh".to_owned()),
cached_mc_token: None,
cached_mc_token_expires_at: None,
}
}
#[test]
fn creates_offline_account_through_store() {
fn creates_offline_account_after_microsoft_account_exists() {
let mut store = MockStore::default();
store.add_account(microsoft_account());
add_offline_account(&mut store, "Steve").expect("offline account should be added");
assert_eq!(store.accounts.len(), 1);
assert_eq!(store.accounts[0].username, "Steve");
assert_eq!(store.accounts[0].account_type, AccountType::Offline);
assert_eq!(store.accounts.len(), 2);
assert_eq!(store.accounts[1].username, "Steve");
assert_eq!(store.accounts[1].account_type, AccountType::Offline);
}
#[test]
fn rejects_offline_account_before_microsoft_account_exists() {
let mut store = MockStore::default();
let err = add_offline_account(&mut store, "Steve")
.expect_err("offline account should require a microsoft account");
assert!(err.to_string().contains("Microsoft account"));
assert!(store.accounts.is_empty());
}
#[test]
+1 -1
View File
@@ -65,7 +65,7 @@ fn manager() -> InstanceManager {
fn list_instances() -> CliResult {
let mut instances = manager().load_all();
instances.sort_by(|left, right| left.name.to_lowercase().cmp(&right.name.to_lowercase()));
instances.sort_by_key(|instance| instance.name.to_lowercase());
let rows = instances
.into_iter()
+53 -17
View File
@@ -8,6 +8,7 @@ use std::path::{Path, PathBuf};
use thiserror::Error;
use crate::auth::{Account, AccountType};
use crate::instance::models::{InstanceConfig, ModLoader};
#[derive(Debug, Error)]
@@ -86,6 +87,10 @@ struct GameAuth {
user_type: String,
}
fn account_can_launch(has_microsoft_account: bool, account: &Account) -> bool {
account.account_type == AccountType::Microsoft || has_microsoft_account
}
// mojang's library rules are a fun little state machine: each rule can allow
// or disallow based on OS. if no rule matches the current OS, the library is
// included only if no rule "dominated" (matched at all). yes, it's weird.
@@ -272,23 +277,25 @@ pub async fn launch(
jvm.extend(config.jvm_args.clone());
// resolve auth credentials, refreshing the microsoft token if needed.
// falls back to a generic offline player if no account is configured.
let mut account_store = crate::auth::AccountStore::load();
let (mc_username, mc_uuid, mc_token, mc_user_type) = match account_store
.active_account()
.cloned()
{
Some(acc) => {
if !account_can_launch(account_store.has_microsoft_account(), &acc) {
return Err(LaunchError::Auth(
"Offline accounts require a Microsoft account that owns Minecraft".to_owned(),
));
}
let (token, new_refresh, new_expires) = match acc.account_type {
crate::auth::AccountType::Microsoft => {
match crate::auth::refresh_and_get_token(&acc).await {
Ok(triple) => triple,
Err(e) => {
return Err(LaunchError::Auth(format!("Authentication failed: {e}")));
}
AccountType::Microsoft => match crate::auth::refresh_and_get_token(&acc).await {
Ok(triple) => triple,
Err(e) => {
return Err(LaunchError::Auth(format!("Authentication failed: {e}")));
}
}
crate::auth::AccountType::Offline => ("0".to_string(), None, None),
},
AccountType::Offline => ("0".to_string(), None, None),
};
if let Some(stored) = account_store
.accounts
@@ -310,8 +317,8 @@ pub async fn launch(
}
}
let user_type = match acc.account_type {
crate::auth::AccountType::Microsoft => "msa",
crate::auth::AccountType::Offline => "legacy",
AccountType::Microsoft => "msa",
AccountType::Offline => "legacy",
};
(
acc.username.clone(),
@@ -320,12 +327,7 @@ pub async fn launch(
user_type.to_string(),
)
}
None => (
"Player".to_string(),
"00000000-0000-0000-0000-000000000000".to_string(),
"0".to_string(),
"legacy".to_string(),
),
None => return Err(LaunchError::Auth("No account selected".to_owned())),
};
let game_args = build_game_args(
@@ -475,6 +477,7 @@ pub async fn launch(
#[cfg(test)]
mod tests {
use super::*;
use crate::auth::{Account, AccountType};
use chrono::Utc;
fn test_config() -> InstanceConfig {
@@ -493,6 +496,18 @@ mod tests {
}
}
fn test_account(account_type: AccountType) -> Account {
Account {
uuid: "00000000-0000-0000-0000-000000000001".to_owned(),
username: "TestPlayer".to_owned(),
account_type,
active: true,
refresh_token: Some("refresh".to_owned()),
cached_mc_token: None,
cached_mc_token_expires_at: None,
}
}
#[test]
fn game_args_include_empty_user_properties() {
let args = build_game_args(
@@ -522,4 +537,25 @@ mod tests {
.any(|pair| pair == ["--tweakClass", "cpw.mods.fml.common.launcher.FMLTweaker"])
);
}
#[test]
fn offline_account_cannot_launch_without_microsoft_account() {
let offline = test_account(AccountType::Offline);
assert!(!account_can_launch(false, &offline));
}
#[test]
fn offline_account_can_launch_with_microsoft_account() {
let offline = test_account(AccountType::Offline);
assert!(account_can_launch(true, &offline));
}
#[test]
fn microsoft_account_can_launch_without_offline_gate() {
let microsoft = test_account(AccountType::Microsoft);
assert!(account_can_launch(false, &microsoft));
}
}
+55 -6
View File
@@ -26,6 +26,7 @@ pub enum AddMode {
None,
ChooseType,
OfflineNameInput(String),
OfflineBlocked,
ConfirmDelete(usize),
DeviceCodeWaiting {
info: DeviceCodeInfo,
@@ -98,7 +99,11 @@ pub fn handle_key(key_event: &KeyEvent, state: &mut AccountState) -> bool {
true
}
KeyCode::Char('o') | KeyCode::Char('2') => {
state.add_mode = AddMode::OfflineNameInput(String::new());
state.add_mode = if state.store.has_microsoft_account() {
AddMode::OfflineNameInput(String::new())
} else {
AddMode::OfflineBlocked
};
true
}
KeyCode::Esc => {
@@ -111,13 +116,19 @@ pub fn handle_key(key_event: &KeyEvent, state: &mut AccountState) -> bool {
KeyCode::Enter => {
let trimmed = name.trim().to_string();
if !trimmed.is_empty() {
let account = auth::create_offline_account(&trimmed);
state.store.add(account);
if state.list_state.selected.is_none() && !state.store.accounts.is_empty() {
state.list_state.selected = Some(0);
if state.store.has_microsoft_account() {
let account = auth::create_offline_account(&trimmed);
state.store.add(account);
if state.list_state.selected.is_none() && !state.store.accounts.is_empty() {
state.list_state.selected = Some(0);
}
state.add_mode = AddMode::None;
} else {
state.add_mode = AddMode::OfflineBlocked;
}
} else {
state.add_mode = AddMode::None;
}
state.add_mode = AddMode::None;
true
}
KeyCode::Char(c) => {
@@ -138,6 +149,13 @@ pub fn handle_key(key_event: &KeyEvent, state: &mut AccountState) -> bool {
}
_ => true,
},
AddMode::OfflineBlocked => match key_event.code {
KeyCode::Enter | KeyCode::Esc => {
state.add_mode = AddMode::None;
true
}
_ => true,
},
AddMode::DeviceCodeWaiting { .. } => match key_event.code {
KeyCode::Esc => {
state.add_mode = AddMode::None;
@@ -257,6 +275,7 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut A
match &state.add_mode {
AddMode::ChooseType => render_choose_popup(frame),
AddMode::OfflineNameInput(name) => render_offline_popup(frame, name),
AddMode::OfflineBlocked => render_offline_blocked_popup(frame),
AddMode::ConfirmDelete(idx) => render_confirm_delete(frame, state, *idx),
AddMode::DeviceCodeWaiting { info, .. } => render_device_code_popup(frame, info),
AddMode::None => {}
@@ -444,6 +463,36 @@ fn render_offline_popup(frame: &mut Frame, name: &str) {
.render(area, frame.buffer_mut());
}
fn render_offline_blocked_popup(frame: &mut Frame) {
use super::popups::{base::PopupFrame, keybind_line};
let theme = THEME.as_ref();
let area = popup_area(frame, 58, 5);
let border_color = theme.text_dim();
let bg_color = theme.surface();
let text_color = theme.text();
PopupFrame {
title: Line::from(Span::styled(
" Offline Account ",
Style::default()
.fg(border_color)
.add_modifier(Modifier::BOLD),
))
.centered(),
border_color,
bg: Some(bg_color),
keybinds: Some(keybind_line(&[("Enter", " close")])),
search_line: None,
content: Box::new(move |inner, buf| {
Paragraph::new("Add a Microsoft account that owns Minecraft first.")
.style(Style::default().fg(text_color))
.render(inner, buf);
}),
}
.render(area, frame.buffer_mut());
}
fn render_confirm_delete(frame: &mut Frame, state: &AccountState, idx: usize) {
use super::popups::{base::PopupFrame, keybind_line};
let theme = THEME.as_ref();
@@ -164,10 +164,8 @@ fn handle_version_key(
state.version_idx = 0;
state.version_search.deactivate();
}
KeyCode::Char('j') | KeyCode::Down => {
if visible_count > 0 {
state.version_idx = (state.version_idx + 1).min(visible_count.saturating_sub(1));
}
KeyCode::Char('j') | KeyCode::Down if visible_count > 0 => {
state.version_idx = (state.version_idx + 1).min(visible_count.saturating_sub(1));
}
KeyCode::Char('k') | KeyCode::Up => {
state.version_idx = state.version_idx.saturating_sub(1);
+5 -9
View File
@@ -202,10 +202,8 @@ fn handle_version_key(
KeyCode::Left | KeyCode::Char('h') if !state.version_search.active => {
state.step = WizardStep::Loader;
}
KeyCode::Char('j') | KeyCode::Down => {
if visible_count > 0 {
state.version_idx = (state.version_idx + 1).min(visible_count.saturating_sub(1));
}
KeyCode::Char('j') | KeyCode::Down if visible_count > 0 => {
state.version_idx = (state.version_idx + 1).min(visible_count.saturating_sub(1));
}
KeyCode::Char('k') | KeyCode::Up => {
state.version_idx = state.version_idx.saturating_sub(1);
@@ -286,11 +284,9 @@ fn handle_loader_version_key(
match key_event.code {
KeyCode::Esc => close_popup(state, instances_state),
KeyCode::Left | KeyCode::Char('h') => state.step = WizardStep::Version,
KeyCode::Char('j') | KeyCode::Down => {
if version_count > 0 {
state.loader_version_idx =
(state.loader_version_idx + 1).min(version_count.saturating_sub(1));
}
KeyCode::Char('j') | KeyCode::Down if version_count > 0 => {
state.loader_version_idx =
(state.loader_version_idx + 1).min(version_count.saturating_sub(1));
}
KeyCode::Char('k') | KeyCode::Up => {
state.loader_version_idx = state.loader_version_idx.saturating_sub(1);
+1 -5
View File
@@ -155,11 +155,7 @@ impl ScreenshotsState {
}
fn ensure_visible(&mut self) {
let row = if self.cols > 0 {
self.selected / self.cols
} else {
0
};
let row = self.selected.checked_div(self.cols).unwrap_or(0);
if row < self.scroll_row {
self.scroll_row = row;
+228
View File
@@ -0,0 +1,228 @@
<?xml version='1.0' encoding='windows-1252'?>
<!--
Copyright (C) 2017 Christopher R. Field.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
The "cargo wix" subcommand provides a variety of predefined variables available
for customization of this template. The values for each variable are set at
installer creation time. The following variables are available:
TargetTriple = The rustc target triple name.
TargetEnv = The rustc target environment. This is typically either
"msvc" or "gnu" depending on the toolchain downloaded and
installed.
TargetVendor = The rustc target vendor. This is typically "pc", but Rust
does support other vendors, like "uwp".
CargoTargetBinDir = The complete path to the directory containing the
binaries (exes) to include. The default would be
"target\release\". If an explicit rustc target triple is
used, i.e. cross-compiling, then the default path would
be "target\<CARGO_TARGET>\<CARGO_PROFILE>",
where "<CARGO_TARGET>" is replaced with the "CargoTarget"
variable value and "<CARGO_PROFILE>" is replaced with the
value from the "CargoProfile" variable. This can also
be overridden manually with the "target-bin-dir" flag.
CargoTargetDir = The path to the directory for the build artifacts, i.e.
"target".
CargoProfile = The cargo profile used to build the binaries
(usually "debug" or "release").
Version = The version for the installer. The default is the
"Major.Minor.Fix" semantic versioning number of the Rust
package.
-->
<!--
Please do not remove these pre-processor If-Else blocks. These are used with
the `cargo wix` subcommand to automatically determine the installation
destination for 32-bit versus 64-bit installers. Removal of these lines will
cause installation errors.
-->
<?if $(sys.BUILDARCH) = x64 or $(sys.BUILDARCH) = arm64 ?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product
Id='*'
Name='mcl-launcher'
UpgradeCode='BEC08BE4-6A8F-4C1D-A1B4-B1AC963000AE'
Manufacturer='objz'
Language='1033'
Codepage='1252'
Version='$(var.Version)'>
<Package Id='*'
Keywords='Installer'
Description='A fully featured Minecraft launcher TUI'
Manufacturer='objz'
InstallerVersion='450'
Languages='1033'
Compressed='yes'
InstallScope='perMachine'
SummaryCodepage='1252'
/>
<MajorUpgrade
Schedule='afterInstallInitialize'
DowngradeErrorMessage='A newer version of [ProductName] is already installed. Setup will now exit.'/>
<Media Id='1' Cabinet='media1.cab' EmbedCab='yes' DiskPrompt='CD-ROM #1'/>
<Property Id='DiskPrompt' Value='mcl-launcher Installation'/>
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='$(var.PlatformProgramFilesFolder)' Name='PFiles'>
<Directory Id='APPLICATIONFOLDER' Name='mcl-launcher'>
<!--
Enabling the license sidecar file in the installer is a four step process:
1. Uncomment the `Component` tag and its contents.
2. Change the value for the `Source` attribute in the `File` tag to a path
to the file that should be included as the license sidecar file. The path
can, and probably should be, relative to this file.
3. Change the value for the `Name` attribute in the `File` tag to the
desired name for the file when it is installed alongside the `bin` folder
in the installation directory. This can be omitted if the desired name is
the same as the file name.
4. Uncomment the `ComponentRef` tag with the Id attribute value of "License"
further down in this file.
-->
<!--
<Component Id='License' Guid='*'>
<File Id='LicenseFile' Name='ChangeMe' DiskId='1' Source='C:\Path\To\File' KeyPath='yes'/>
</Component>
-->
<Directory Id='Bin' Name='bin'>
<Component Id='Path' Guid='E5863AC2-13FC-45C8-B79D-55338F371A8A' KeyPath='yes'>
<Environment
Id='PATH'
Name='PATH'
Value='[Bin]'
Permanent='no'
Part='last'
Action='set'
System='yes'/>
</Component>
<Component Id='binary0' Guid='*'>
<File
Id='exe0'
Name='mcl.exe'
DiskId='1'
Source='$(var.CargoTargetBinDir)\mcl.exe'
KeyPath='yes'/>
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<Feature
Id='Binaries'
Title='Application'
Description='Installs all binaries and the license.'
Level='1'
ConfigurableDirectory='APPLICATIONFOLDER'
AllowAdvertise='no'
Display='expand'
Absent='disallow'>
<!--
Uncomment the following `ComponentRef` tag to add the license
sidecar file to the installer.
-->
<!--<ComponentRef Id='License'/>-->
<ComponentRef Id='binary0'/>
<Feature
Id='Environment'
Title='PATH Environment Variable'
Description='Add the install location of the [ProductName] executable to the PATH system environment variable. This allows the [ProductName] executable to be called from any location.'
Level='1'
Absent='allow'>
<ComponentRef Id='Path'/>
</Feature>
</Feature>
<SetProperty Id='ARPINSTALLLOCATION' Value='[APPLICATIONFOLDER]' After='CostFinalize'/>
<!--
Uncomment the following `Icon` and `Property` tags to change the product icon.
The product icon is the graphic that appears in the Add/Remove
Programs control panel for the application.
-->
<!--<Icon Id='ProductICO' SourceFile='wix\Product.ico'/>-->
<!--<Property Id='ARPPRODUCTICON' Value='ProductICO' />-->
<Property Id='ARPHELPLINK' Value='https://github.com/objz/mcl'/>
<UI>
<UIRef Id='WixUI_FeatureTree'/>
<!--
Enabling the EULA dialog in the installer is a three step process:
1. Comment out or remove the two `Publish` tags that follow the
`WixVariable` tag.
2. Uncomment the `<WixVariable Id='WixUILicenseRtf' Value='Path\to\Eula.rft'>` tag further down
3. Replace the `Value` attribute of the `WixVariable` tag with
the path to a RTF file that will be used as the EULA and
displayed in the license agreement dialog.
-->
<Publish Dialog='WelcomeDlg' Control='Next' Event='NewDialog' Value='CustomizeDlg' Order='99'>1</Publish>
<Publish Dialog='CustomizeDlg' Control='Back' Event='NewDialog' Value='WelcomeDlg' Order='99'>1</Publish>
</UI>
<!--
Enabling the EULA dialog in the installer requires uncommenting
the following `WixUILicenseRTF` tag and changing the `Value`
attribute.
-->
<!-- <WixVariable Id='WixUILicenseRtf' Value='Relative\Path\to\Eula.rtf'/> -->
<!--
Uncomment the next `WixVariable` tag to customize the installer's
Graphical User Interface (GUI) and add a custom banner image across
the top of each screen. See the WiX Toolset documentation for details
about customization.
The banner BMP dimensions are 493 x 58 pixels.
-->
<!--<WixVariable Id='WixUIBannerBmp' Value='wix\Banner.bmp'/>-->
<!--
Uncomment the next `WixVariable` tag to customize the installer's
Graphical User Interface (GUI) and add a custom image to the first
dialog, or screen. See the WiX Toolset documentation for details about
customization.
The dialog BMP dimensions are 493 x 312 pixels.
-->
<!--<WixVariable Id='WixUIDialogBmp' Value='wix\Dialog.bmp'/>-->
</Product>
</Wix>