name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
release:
name: Releasing ${{ matrix.job.target }}
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
job:
- target: x86_64-apple-darwin
os: macos-latest
use-cross: false
- target: i686-pc-windows-msvc
os: windows-latest
use-cross: false
- target: x86_64-pc-windows-msvc
os: windows-latest
use-cross: false
- target: i686-pc-windows-gnu
os: ubuntu-latest
use-cross: true
- target: x86_64-pc-windows-gnu
os: ubuntu-latest
use-cross: true
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
use-cross: true
steps:
- name: Installing Rust toolchain
uses: dtolnay/rust-toolchain@master
if: ${{ matrix.job.use-cross == false }}
with:
toolchain: stable
target: ${{ matrix.job.target }}
- name: Checkout repository
uses: actions/checkout@v3
- name: Cargo build
env:
RUSTFLAGS: "-Dwarnings"
MACOSX_DEPLOYMENT_TARGET: 10.7
uses: actions-rs/cargo@v1
with:
command: build
use-cross: ${{ matrix.job.use-cross }}
args: --locked --release --target ${{ matrix.job.target }}
- name: Build package
shell: bash
run: |
pkg_name="aoc-cli-${GITHUB_REF_NAME}-${{ matrix.job.target }}"
mkdir "$pkg_name"
cp {README.md,LICENSE} "$pkg_name/"
if [[ "${{ matrix.job.target }}" == *"windows"* ]]; then
cp "target/${{ matrix.job.target }}/release/aoc.exe" "$pkg_name/"
if [ "${{ matrix.job.os }}" = "windows-latest" ]; then
7z a "$pkg_name.zip" "$pkg_name"
else
zip -r "$pkg_name.zip" "$pkg_name"
fi
else
cp "target/${{ matrix.job.target }}/release/aoc" "$pkg_name/"
tar czvf "$pkg_name.tar.gz" "$pkg_name"
fi
- name: Install cargo-wix
if: matrix.job.target == 'x86_64-pc-windows-msvc'
run: cargo install cargo-wix
- name: Build Windows installer
if: matrix.job.target == 'x86_64-pc-windows-msvc'
run: cargo wix --verbose
- name: Release packages
uses: softprops/action-gh-release@v1
with:
files: |
aoc-cli-*-${{ matrix.job.target }}.*
target/wix/aoc-cli-*-x86_64.msi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crate:
name: Publish crate
needs: release
runs-on: ubuntu-latest
environment: Release
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CARGO_API_TOKEN }}
publish-windows:
name: Update Windows Package Manager repository
needs: release
runs-on: windows-latest
environment: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
steps:
- name: Run wingetcreate
shell: powershell
run: |
# Download and install C++ Runtime framework
$VCLIBS_INSTALLER = "MicrosoftVCLibs.appx"
iwr https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile ${VCLIBS_INSTALLER}
Add-AppxPackage ${VCLIBS_INSTALLER}
# Download and install WingetCreate
$WINGETCREATE_INSTALLER = "WingetCreateInstaller.msixbundle"
iwr https://aka.ms/wingetcreate/latest/msixbundle -OutFile ${WINGETCREATE_INSTALLER}
Add-AppxPackage ${WINGETCREATE_INSTALLER}
$RELEASE_VER = "${env:GITHUB_REF_NAME}"
$PACKAGE_URL = "https://github.com/scarvalhojr/aoc-cli/releases/download/${RELEASE_VER}/aoc-cli-${RELEASE_VER}-x86_64.msi"
wingetcreate update scarvalhojr.aoc-cli --urls ${PACKAGE_URL} --version ${RELEASE_VER} --token "${env:GITHUB_TOKEN}" --submit