Fix binary name on windows #22
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by https://github.com/kowainik/stan/blob/30ae41dccde49feefe19913039014f3612e5d44c/.github/workflows/release.yml | |
name: Release | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
create_release: | |
name: Create Github Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1.1.4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: true | |
prerelease: false | |
- name: Output Release URL File | |
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt | |
- name: Save Release URL File for publish | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release_url | |
path: release_url.txt | |
build_artifact: | |
needs: [create_release] | |
name: ${{ matrix.os }}/${{ matrix.arch }}/${{ github.ref }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# - os: ubuntu-latest | |
# arch: aarch64 | |
- os: ubuntu-latest | |
arch: x86_64 | |
- os: macOS-13 # macOS-latest does something weird I don't understand | |
arch: aarch64 | |
# - os: macOS-13 # macOS-latest does something weird I don't understand | |
# arch: x86_64 | |
- os: windows-latest | |
arch: x86_64 | |
# - os: windows-latest | |
# arch: aarch64 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set tag name | |
uses: olegtarasov/get-tag@2.1.3 | |
id: tag | |
with: | |
tagRegex: "v(.*)" | |
tagRegexGroup: 1 | |
- name: Setup Haskell | |
uses: haskell-actions/setup@v2.7.3 | |
with: | |
ghc-version: 9.6.5 | |
enable-stack: true | |
stack-version: 2.15.7 | |
- name: Cache ~/.stack | |
uses: actions/cache@v4 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-9.6.5-${{ matrix.arch }}-${{ hashFiles('**/stack.yaml.lock','**/gitlab-helper.cabal') }}-v2 | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.arch }}-9.6.5- | |
- name: Build binary | |
run: | | |
mkdir bin | |
stack build --copy-bins --local-bin-path bin | |
- if: matrix.os == 'windows-latest' | |
name: Set binary path name on Windows | |
run: | | |
mv ./bin/gitlab-helper-exe.exe ./bin/gitlab-helper.exe | |
echo "BINARY_PATH=./bin/gitlab-helper.exe" >> $env:GITHUB_ENV | |
- if: matrix.os != 'windows-latest' | |
name: Set binary path name not on Windows | |
run: | | |
mv ./bin/gitlab-helper-exe ./bin/gitlab-helper | |
echo "BINARY_PATH=./bin/gitlab-helper" >> "$GITHUB_ENV" | |
- name: Compress binary | |
uses: svenstaro/upx-action@2.4.1 | |
with: | |
file: ${{ env.BINARY_PATH }} | |
- if: matrix.os == 'windows-latest' | |
name: Set zip file path name on Windows | |
run: | | |
echo "ZIP_PATH=./bin/gitlab-helper.zip" >> $env:GITHUB_ENV | |
- if: matrix.os != 'windows-latest' | |
name: Set zip file path name not on Windows | |
run: | | |
echo "ZIP_PATH=./bin/gitlab-helper.zip" >> "$GITHUB_ENV" | |
- name: Create zip file | |
run: | | |
7z a -l ${{ env.ZIP_PATH }} ${{ env.BINARY_PATH }} | |
- name: Load Release URL File from release job | |
uses: actions/download-artifact@v4 | |
with: | |
name: release_url | |
path: release_url | |
- if: matrix.os == 'windows-latest' | |
name: Get Release File Name & Upload URL on Widows | |
run: | | |
echo "upload_url=$(cat release_url/release_url.txt)" >> $env:GITHUB_ENV | |
- if: matrix.os != 'windows-latest' | |
name: Get Release File Name & Upload URL not on Widows | |
run: | | |
echo "upload_url=$(cat release_url/release_url.txt)" >> $GITHUB_ENV | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1.0.2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ env.upload_url }} | |
asset_path: ${{ env.ZIP_PATH }} | |
asset_name: gitlab-helper-${{ steps.tag.outputs.tag }}-${{ runner.os }}.zip | |
asset_content_type: application/zip |