Merge pull request #110 from rradczewski/feature/add-envvars #29
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
name: Release | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-20.04 | |
outputs: | |
release_upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- id: create_release | |
name: Create the release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref }} | |
body: ${{ github.ref }} | |
draft: true | |
publish-unix: | |
name: Publish | |
needs: release | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-20.04 | |
- macos-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
- name: Get GHC version | |
id: ghc-version | |
run: echo "ghc-version=$(cat ghc.version)" >> "$GITHUB_OUTPUT" | |
- name: Set up Haskell | |
id: haskell-setup | |
uses: haskell/actions/setup@v2 | |
with: | |
ghc-version: ${{ steps.ghc-version.outputs.ghc-version }} | |
enable-stack: true | |
stack-no-global: true | |
stack-setup-ghc: true | |
- name: Cache the Stack directory | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.haskell-setup.outputs.stack-root }} | |
key: v1-${{ matrix.os }}-stack-${{ hashFiles('stack.yaml', 'package.yaml') }} | |
- name: Install dependencies | |
run: stack --no-terminal install --only-dependencies --test --no-run-tests | |
- name: Build for release | |
run: stack --no-terminal install --local-bin-path=./out/build/release | |
- name: Check version | |
run: | | |
TAG='${{ github.ref }}' | |
EXPECTED_VERSION_STRING="Smoke ${TAG##*/}" | |
ACTUAL_VERSION_STRING="$(./out/build/release/smoke --version)" | |
if [[ "$ACTUAL_VERSION_STRING" != "$EXPECTED_VERSION_STRING" ]]; then | |
echo "Invalid version!" | |
echo "Expected: ${EXPECTED_VERSION_STRING}" | |
echo "Actual: ${ACTUAL_VERSION_STRING}" | |
exit 1 | |
fi | |
- id: asset | |
name: Set the asset information | |
run: | | |
export TAG='${{ github.ref }}' | |
echo "asset_name=smoke-${TAG##*/}-$(uname -s)-$(uname -m)" >> "$GITHUB_OUTPUT" | |
echo "asset_path=out/build/release/smoke" >> "$GITHUB_OUTPUT" | |
- name: Upload the asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.release_upload_url }} | |
asset_name: ${{ steps.asset.outputs.asset_name }} | |
asset_path: ${{ steps.asset.outputs.asset_path }} | |
asset_content_type: application/octet-stream | |
publish-windows: | |
name: Publish (windows-latest) | |
needs: release | |
runs-on: windows-latest | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
- name: Cache Stack | |
uses: actions/cache@v3 | |
with: | |
path: C:\Users\runneradmin\AppData\Local\Programs\stack | |
key: v1-windows-latest-stack-${{ hashFiles('stack.yaml') }} | |
- name: Get GHC version | |
id: ghc-version | |
run: echo "ghc-version=$(Get-Content ghc.version)" >> "$Env:GITHUB_OUTPUT" | |
- name: Set up Haskell | |
id: haskell-setup | |
uses: haskell/actions/setup@v2 | |
with: | |
ghc-version: ${{ steps.ghc-version.outputs.ghc-version }} | |
enable-stack: true | |
stack-no-global: true | |
stack-setup-ghc: true | |
- name: Cache the Stack root | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.haskell-setup.outputs.stack-root }} | |
key: v1-windows-latest-stack-root-${{ hashFiles('stack.yaml', 'package.yaml') }} | |
- name: Update MSYS2 | |
run: | | |
stack --no-terminal exec -- pacman --noconfirm -Sy msys2-keyring | |
stack --no-terminal exec -- pacman --noconfirm -Syuu | |
- name: Build for release | |
run: 'stack --no-terminal install --local-bin-path=.\out\build\release' | |
- name: Check version | |
run: | | |
$ExpectedVersionString = 'Smoke ' + ('${{ github.ref }}' -replace '.+/', '') | |
$ActualVersionString = .\out\build\release\smoke.exe --version | |
if ( $ActualVersionString -ne $ExpectedVersionString ) { | |
echo "Invalid version!" | |
echo "Expected: ${ExpectedVersionString}" | |
echo "Actual: ${ActualVersionString}" | |
exit 1 | |
} | |
- id: asset | |
name: Set the asset information | |
run: | | |
$Tag = '${{ github.ref }}' -replace '.+/', '' | |
echo "asset_name=smoke-${Tag}-windows-x64.exe" >> "$Env:GITHUB_OUTPUT" | |
echo "asset_path=out\build\release\smoke.exe" >> "$Env:GITHUB_OUTPUT" | |
- name: Upload the asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.release_upload_url }} | |
asset_name: ${{ steps.asset.outputs.asset_name }} | |
asset_path: ${{ steps.asset.outputs.asset_path }} | |
asset_content_type: application/octet-stream |