Skip to content

Deploy

Deploy #37

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
push:
tags:
- 'v**'
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
GH_TOKEN: ${{ github.token }}
jobs:
# We always fetch the cargo version, it's used in some places below...
fetch-version:
name: Fetch version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Get version
id: get-version
shell: bash
run: echo "version=$(cargo pkgid -p portablemc | awk -F'[#@]' '{print $NF}')" >> $GITHUB_OUTPUT
# We only check the cargo version if we are running the workflow against a tag.
check-version:
name: Check version against tag
needs: fetch-version
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
steps:
- name: Match cargo version with tag
shell: bash
run: test "v${{ needs.fetch-version.outputs.version }}" = "${{ github.ref_name }}"
# We only build when the current cargo version has been checked OR we have manually
# dispatched the workflow!
build:
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc
- aarch64-unknown-linux-gnu
- arm-unknown-linux-gnueabihf
include:
# ubuntu-24.04 (x86_64)
- target: x86_64-unknown-linux-gnu
image: ubuntu-24.04
- target: i686-unknown-linux-gnu
image: ubuntu-24.04
setup: |
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libssl-dev:i386 gcc-multilib
echo 'OPENSSL_INCLUDE_DIR=/usr/include' >> $GITHUB_ENV
echo 'OPENSSL_LIB_DIR=/usr/lib/i386-linux-gnu' >> $GITHUB_ENV
# macos-15 (x86_64)
- target: x86_64-apple-darwin
image: macos-15-intel
# macos-15 (aarch64)
- target: aarch64-apple-darwin
image: macos-15
# windows-2022 (x86_64)
- target: x86_64-pc-windows-msvc
image: windows-2022
- target: i686-pc-windows-msvc
image: windows-2022
# ubuntu-24.04-arm (aarch64)
- target: aarch64-unknown-linux-gnu
image: ubuntu-24.04-arm
- target: arm-unknown-linux-gnueabihf
image: ubuntu-24.04-arm
skip_test: true
setup: |
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install libssl-dev:armhf gcc-arm-linux-gnueabihf
echo 'OPENSSL_INCLUDE_DIR=/usr/include' >> $GITHUB_ENV
echo 'OPENSSL_LIB_DIR=/usr/lib/arm-linux-gnueabihf' >> $GITHUB_ENV
echo 'CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=/usr/bin/arm-linux-gnueabihf-gcc' >> $GITHUB_ENV
name: Build ${{ matrix.target }} on ${{ matrix.image }}
needs: check-version # Note that this already depends on github.ref being a tag...
if: ${{ always() && (github.event_name == 'workflow_dispatch' || (needs.check-version.result == 'success' && !contains(github.ref, '-beta') && !contains(github.ref, '-alpha'))) }}
runs-on: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4
- name: Setup
if: matrix.setup != null
run: ${{ matrix.setup }}
- name: Setup rust
run: rustup target add ${{ matrix.target }}
- name: Test (debug)
if: matrix.skip_test == null
run: cargo test --target ${{ matrix.target }} --workspace --exclude portablemc-py --exclude portablemc-ffi -- --include-ignored
- name: Build (release)
run: cargo build --target ${{ matrix.target }} --release --workspace --exclude portablemc-py --exclude portablemc-ffi
- name: Debug path
run: ls ./target/${{ matrix.target }}/release
- name: Collect artifacts
shell: bash
run: |
mkdir -p ~/portablemc/dev
# cp -r ./portablemc-ffi/include ~/portablemc/dev/
cp .github/workflows/data/target-readme.txt ~/portablemc/readme.txt
- name: Collect artifacts (linux)
if: contains(matrix.target, 'linux')
run: |
cd ./target/${{ matrix.target }}/release/
cp portablemc ~/portablemc/
# cp libportablemc_ffi.so ~/portablemc/libportablemc.so
# cp libportablemc_ffi.a ~/portablemc/dev/libportablemc.a
- name: Collect artifacts (apple)
if: contains(matrix.target, 'apple')
run: |
cd ./target/${{ matrix.target }}/release/
cp portablemc ~/portablemc/
# cp libportablemc_ffi.dylib ~/portablemc/libportablemc.dylib
# cp libportablemc_ffi.a ~/portablemc/dev/libportablemc.a
- name: Collect artifacts (windows)
if: contains(matrix.target, 'windows')
shell: bash
run: |
cd ./target/${{ matrix.target }}/release/
cp portablemc.exe ~/portablemc/
# cp portablemc_ffi.dll ~/portablemc/portablemc.dll
cp portablemc.pdb ~/portablemc/dev/portablemc.exe.pdb
# cp portablemc_ffi.pdb ~/portablemc/dev/portablemc.dll.pdb
# cp portablemc_ffi.dll.exp ~/portablemc/dev/portablemc.dll.exp
# cp portablemc_ffi.dll.lib ~/portablemc/dev/portablemc.dll.lib
# cp portablemc_ffi.lib ~/portablemc/dev/portablemc.lib
- name: Upload workflow artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: ~/portablemc/
release:
name: Release
needs:
- fetch-version
- check-version # This requires that github.ref is a tag...
- build # and this checks that this is not a beta/alpha
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download workflow artifacts
id: download-workflow-artifacts
uses: actions/download-artifact@v4
with:
path: ~/artifacts
- name: Archiving artifacts
shell: bash
run: |
cd ~/artifacts
tree
for target in *; do
cd $target
target_description=$(rustc +nightly --target $target -Z unstable-options --print target-spec-json | jq -r '.metadata.description')
echo "Version: ${{ needs.fetch-version.outputs.version }}" >> readme.txt
echo "Target: $target" >> readme.txt
echo " $target_description" >> readme.txt
zip -r ../$target.zip *
cd ..
done
- name: Create release
shell: bash
run: gh release create ${{ github.ref_name }} --verify-tag --draft --title "Version ${{ needs.fetch-version.outputs.version }}" --notes-file .github/workflows/data/release-notes.md ~/artifacts/*.zip
publish:
name: Publish
needs: check-version # This checks that github.ref is a tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish API
run: cargo publish -p portablemc
- name: Publish CLI
run: cargo publish -p portablemc-cli