Skip to content

ci(release): use Ubuntu to build Windows binaries #37

ci(release): use Ubuntu to build Windows binaries

ci(release): use Ubuntu to build Windows binaries #37

Workflow file for this run

name: Release
on:
push:
tags:
- '*.*.*'
workflow_dispatch:
env:
APP_NAME: 'nasher'
NIM_VERSION: '2.0.2'
MAINTAINER: 'Michael A. Sinclair <[email protected]>'
RELEASE_FILES: nasher LICENSE README.md CHANGELOG.md
jobs:
build-artifact:
strategy:
matrix:
include:
- target: linux
builder: ubuntu-latest
- target: macos
builder: macOS-latest
- target: windows
builder: ubuntu-latest
defaults:
run:
shell: bash
name: '${{ matrix.target}}'
runs-on: '${{ matrix.builder }}'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache choosenim
id: cache-choosenim
uses: actions/cache@v4
with:
path: ~/.choosenim
key: ${{ matrix.target }}-choosenim-${{ env.NIM_VERSION }}
- name: Cache nimble
id: cache-nimble
uses: actions/cache@v4
with:
path: ~/.nimble
key: ${{ matrix.target }}-nimble-${{ env.NIM_VERSION }}-${{ hashFiles('nasher.nimble') }}
restore-keys: |
${{ matrix.target }}-nimble-${{ env.NIM_VERSION }}
- name: Install mingw
if: matrix.target == 'windows'
run: sudo apt-get install -y --no-install-recommends mingw-w64
- name: Set up nim
uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ env.NIM_VERSION }}
- name: Create release binary
run: |
if [[ "${{ matrix.target }}" == windows ]]; then
nimble build -Y -d:release -d:mingw --cpu:amd64
else
nimble build -Y -d:release
fi
- name: Create artifact
run: |
if [[ "${{ matrix.target }}" == windows ]]; then
zip "${{ env.APP_NAME }}_${{ matrix.target }}.zip" nasher.exe CHANGELOG.md README.md LICENSE
else
chmod +x nasher
tar -czvf "${{ env.APP_NAME }}_${{ matrix.target }}.tar.gz" nasher CHANGELOG.md README.md LICENSE
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.target }}
path: |
*.zip
*.tar.gz
create-release:
needs: [ build-artifact ]
runs-on: ubuntu-latest
steps:
- name: Create release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Write upload_url to file
run: echo '${{ steps.create-release.outputs.upload_url }}' > upload_url.txt
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: create-release
path: upload_url.txt
upload-release:
needs: [ create-release ]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: linux
asset_name_suffix: linux.tar.gz
asset_content_type: application/gzip
- target: windows
asset_name_suffix: windows.zip
asset_content_type: application/zip
- target: macos
asset_name_suffix: macos.tar.gz
asset_content_type: application/gzip
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifact-${{ matrix.target }}
- name: Download upload_url
uses: actions/download-artifact@v4
with:
name: create-release
- name: Create vars
id: vars
run: |
echo "::set-output name=upload_url::$(cat upload_url.txt)"
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.vars.outputs.upload_url }}
asset_path: ${{ env.APP_NAME }}_${{ matrix.asset_name_suffix }}
asset_name: ${{ env.APP_NAME }}_${{ matrix.asset_name_suffix }}
asset_content_type: ${{ matrix.asset_content_type }}