Skip to content

fix windows self-upgrades and add more backup options #17

fix windows self-upgrades and add more backup options

fix windows self-upgrades and add more backup options #17

Workflow file for this run

name: Release
on:
# schedule:
# - cron: '0 0 * * *' # midnight UTC
push:
branches:
- main
env:
BIN_NAME: mcvcli
PROJECT_NAME: mcvcli
REPO_NAME: mcjars/mcvcli
jobs:
dist:
name: Dist
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # don't fail other jobs if one fails
matrix:
build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
include:
- build: x86_64-linux
os: ubuntu-20.04
rust: stable
target: x86_64-unknown-linux-gnu
cross: false
# - build: aarch64-linux
# os: ubuntu-20.04
# rust: stable
# target: aarch64-unknown-linux-gnu
# cross: true
- build: x86_64-macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
- build: x86_64-windows
os: windows-2019
rust: stable
target: x86_64-pc-windows-msvc
cross: false
# - build: aarch64-macos
# os: macos-latest
# rust: stable
# target: aarch64-apple-darwin
# - build: x86_64-win-gnu
# os: windows-2019
# rust: stable-x86_64-gnu
# target: x86_64-pc-windows-gnu
# - build: win32-msvc
# os: windows-2019
# rust: stable
# target: i686-pc-windows-msvc
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install ${{ matrix.rust }} toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: test
args: --release --target ${{ matrix.target }}
- name: Build release binary
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --target ${{ matrix.target }}
- name: Strip release binary (linux and macos)
if: matrix.build == 'x86_64-linux' || matrix.build == 'x86_64-macos'
run: strip "target/${{ matrix.target }}/release/$BIN_NAME"
# - name: Strip release binary (arm)
# if: matrix.build == 'aarch64-linux'
# run: |
# docker run --rm -v \
# "$PWD/target:/target:Z" \
# rustembedded/cross:${{ matrix.target }} \
# aarch64-linux-gnu-strip \
# /target/${{ matrix.target }}/release/$BIN_NAME
- name: Build archive
shell: bash
run: |
mkdir dist
if [ "${{ matrix.os }}" = "windows-2019" ]; then
cp "target/${{ matrix.target }}/release/$BIN_NAME.exe" "dist/"
else
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/"
fi
- uses: actions/upload-artifact@v4
with:
name: bins-${{ matrix.build }}
path: dist
publish:
name: Publish
needs: [dist]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: false
- uses: actions/download-artifact@v4
# with:
# path: dist
# - run: ls -al ./dist
- run: ls -al bins-*
- name: Build archive
shell: bash
run: |
set -ex
rm -rf tmp
mkdir tmp
mkdir dist
for dir in bins-* ; do
platform=${dir#"bins-"}
unset exe
if [[ $platform =~ "windows" ]]; then
exe=".exe"
fi
pkgname=$PROJECT_NAME-$platform
mkdir tmp/$pkgname
# cp LICENSE README.md tmp/$pkgname
mv bins-$platform/$BIN_NAME$exe tmp/$pkgname
chmod +x tmp/$pkgname/$BIN_NAME$exe
if [ "$exe" = "" ]; then
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
else
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
fi
done
- name: Get cli version from Cargo.toml
id: version
run: echo "val=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' -r)" >> $GITHUB_OUTPUT
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
file_glob: true
tag: ${{ steps.version.outputs.val }}
overwrite: true
#
# you can use this initial file in your homebrew-tap if you don't have an initial formula:
# <projectname>.rb
#
# class <Projectname capitalized> < Formula
# desc "A test formula"
# homepage "http://www.example.com"
# url "-----"
# version "-----"
# sha256 "-----"
# def install
# bin.install "<bin-name>"
# end
# end
# Uncomment this section if you want to release your package to crates.io
# Before publishing, make sure you have filled out the following fields:
# license or license-file, description, homepage, documentation, repository, readme.
# Read more: https://doc.rust-lang.org/cargo/reference/publishing.html
# - name: Install ${{ matrix.rust }} toolchain
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: ${{ matrix.rust }}
# target: ${{ matrix.target }}
# - run: cargo publish --token ${CRATES_TOKEN}
# env:
# CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}