Skip to content

Build and release binary #10

Build and release binary

Build and release binary #10

Workflow file for this run

name: "Build and release binary"
on:
workflow_dispatch:
push:
tags:
- "misrc_extract-*"
env:
ARCHIVE_NAME_LINUX: ${{ github.ref_name }}-linux-x86_64.tar.gz
ARCHIVE_NAME_WINDOWS: ${{ github.ref_name }}-win-x86_64.zip
ARCHIVE_NAME_MACOS_INTEL: ${{ github.ref_name }}-macos-intel-x86_64.tar.gz
ARCHIVE_NAME_MACOS_ARM: ${{ github.ref_name }}-macos-apple-silicon-arm64.tar.gz
ARCHIVE_NAME_SRC: ${{ github.ref_name }}-src.tar.gz
jobs:
build-linux:
name: Build Linux
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: cmake nasm build-essential
version: 1.0
- name: Build
run: |
cmake -B ${{ github.workspace }}/misrc_extract/build \
${{ github.workspace }}/misrc_extract
cmake --build ${{ github.workspace }}/misrc_extract/build
- name: Create binary archive
run: >-
tar -cvzf ${{ env.ARCHIVE_NAME_LINUX }}
--owner=root --group=root
-C ${{ github.workspace }}/misrc_extract/build
misrc_extract
- name: Create source archive
run: >-
tar -cvzf ${{ env.ARCHIVE_NAME_SRC }}
--exclude=build
misrc_extract
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: misrc_extract-linux
path: ${{ env.ARCHIVE_NAME_LINUX }}
if-no-files-found: error
- name: Upload source artifact
uses: actions/upload-artifact@v4
with:
name: misrc_extract-src
path: ${{ env.ARCHIVE_NAME_SRC }}
if-no-files-found: error
build-windows:
name: Build Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install winget
uses: Cyberboss/install-winget@v1
- name: Install MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Install NASM
run: >-
winget install
--disable-interactivity
--accept-source-agreements
--accept-package-agreements
--silent --exact --id NASM.NASM
- name: Build
run: |
cmake -B ${{ github.workspace }}\misrc_extract/build `
${{ github.workspace }}\misrc_extract
cmake --build ${{ github.workspace }}\misrc_extract/build --config Release
- name: Create binary archive
run: >-
Compress-Archive `
-Path ${{ github.workspace }}\misrc_extract\build\Release\misrc_extract.exe `
${{ env.ARCHIVE_NAME_WINDOWS }}
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: misrc_extract-windows
path: ${{ env.ARCHIVE_NAME_WINDOWS }}
if-no-files-found: error
build-macos-intel:
name: Build macOS (Intel)
runs-on: macos-11
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install
run: |
brew install cmake nasm
- name: Build
run: |
cmake -B ${{ github.workspace }}/misrc_extract/build \
${{ github.workspace }}/misrc_extract
cmake --build ${{ github.workspace }}/misrc_extract/build
- name: Create binary archive
run: >-
tar -cvzf ${{ env.ARCHIVE_NAME_MACOS_INTEL }}
--uid 0 --gid 0 --no-acls
-C ${{ github.workspace }}/misrc_extract/build
misrc_extract
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: misrc_extract-macos-intel
path: ${{ env.ARCHIVE_NAME_MACOS_INTEL }}
if-no-files-found: error
build-macos-arm:
name: Build macOS (Apple Silicon)
runs-on: macos-11
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install
run: |
brew install cmake
- name: Build
run: |
cmake -B ${{ github.workspace }}/misrc_extract/build \
${{ github.workspace }}/misrc_extract \
-D CMAKE_OSX_ARCHITECTURES=arm64
cmake --build ${{ github.workspace }}/misrc_extract/build
- name: Create binary archive
run: >-
tar -cvzf ${{ env.ARCHIVE_NAME_MACOS_ARM }}
--uid 0 --gid 0 --no-acls
-C ${{ github.workspace }}/misrc_extract/build
misrc_extract
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: misrc_extract-macos-arm
path: ${{ env.ARCHIVE_NAME_MACOS_ARM }}
if-no-files-found: error
github-release:
name: Create GitHub release
runs-on: ubuntu-20.04
needs:
- build-linux
- build-windows
- build-macos-intel
- build-macos-arm
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--title '${{ github.ref_name }}'
--notes ""
- name: Upload artifacts to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload \
'${{ github.ref_name }}' \
'misrc_extract-linux/${{ env.ARCHIVE_NAME_LINUX }}' \
--repo '${{ github.repository }}'
gh release upload \
'${{ github.ref_name }}' \
'misrc_extract-windows/${{ env.ARCHIVE_NAME_WINDOWS }}' \
--repo '${{ github.repository }}'
gh release upload \
'${{ github.ref_name }}' \
'misrc_extract-macos-intel/${{ env.ARCHIVE_NAME_MACOS_INTEL }}' \
--repo '${{ github.repository }}'
gh release upload \
'${{ github.ref_name }}' \
'misrc_extract-macos-arm/${{ env.ARCHIVE_NAME_MACOS_ARM }}' \
--repo '${{ github.repository }}'
gh release upload \
'${{ github.ref_name }}' \
'misrc_extract-src/${{ env.ARCHIVE_NAME_SRC }}' \
--repo '${{ github.repository }}'