Bump actions/checkout from 3 to 4 #190
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: Build by Stack | |
on: | |
push: | |
branches: | |
- master | |
- ci* | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- master | |
- ci* | |
workflow_dispatch: | |
# For making a release, we need write permissions. | |
# TODO: if we split out a release job from the build job, we could make permissions more fine-grained. | |
permissions: | |
contents: write | |
jobs: | |
## Release preparation | |
########################################################################## | |
# From: https://github.com/RobLoach/node-raylib/blob/aca2956e9ed283e5e91b1c8f08fafd943b5d6344/.github/workflows/release.yml | |
create_release: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
# outputs: | |
# upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- uses: actions/checkout@v4 | |
# - name: Create release | |
# id: create_release | |
# uses: actions/create-release@v1 | |
# with: | |
# draft: false | |
# prerelease: false | |
# release_name: fix-whitespace ${{ github.ref }} | |
# tag_name: ${{ github.ref }} | |
# # body: fix-whitespace binary release created from ${{ github.ref }} | |
# env: | |
# GITHUB_TOKEN: ${{ github.token }} | |
- name: Source tarball creation | |
run: | | |
cabal sdist | |
DIST_TGZ_PATH=$(cabal sdist | tail -1) | |
DIST_TGZ_NAME=$(basename "${DIST_TGZ_PATH}") | |
echo "DIST_TGZ_PATH=${DIST_TGZ_PATH}" >> "${GITHUB_ENV}" | |
echo "DIST_TGZ_NAME=${DIST_TGZ_NAME}" >> "${GITHUB_ENV}" | |
# - name: Source tarball release | |
# uses: actions/upload-release-asset@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ github.token }} | |
# with: | |
# upload_url: ${{ steps.create_release.outputs.upload_url }} | |
# asset_path: ${{ env.DIST_TGZ_PATH }} | |
# asset_name: ${{ env.DIST_TGZ_NAME }} | |
# asset_content_type: application/octet-stream | |
- name: Create release, upload source tarball | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
gh release create ${{ github.ref }} "${{ env.DIST_TGZ_PATH }}#${{ env.DIST_TGZ_NAME }}" --title "fix-whitespace ${{ github.ref }}" --generate-notes | |
build: | |
# Run this job even if the previous was skipped. | |
if: ${{ !failure() }} | |
runs-on: ${{ matrix.os }} | |
needs: create_release | |
strategy: | |
matrix: | |
os: [ubuntu-22.04] | |
ghc-ver: [9.6.2, 9.4.5, 9.2.8, 9.0.2, 8.10.7, 8.8.4, 8.6.5, 8.4.4] | |
include: | |
- os: windows-2022 | |
ghc-ver: 9.6.2 | |
- os: macos-12 | |
ghc-ver: 9.6.2 | |
fail-fast: false | |
env: | |
ARGS: "--stack-yaml stack-${{ matrix.ghc-ver }}.yaml --no-terminal --system-ghc" | |
# Needed for Windows to make piping (... >> ...) and evaluation ( $(...) ) work. | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Workaround runner image issue (ghcup, Linux) | |
if: ${{ runner.os == 'Linux' }} | |
# https://github.com/actions/runner-images/issues/7061 | |
run: sudo chown -R "$USER" /usr/local/.ghcup | |
- uses: haskell/actions/setup@v2 | |
id: haskell-setup | |
with: | |
ghc-version: ${{ matrix.ghc-ver }} | |
stack-version: 'latest' | |
enable-stack: true | |
- name: Set environment variables based on Haskell setup | |
run: | | |
STACK_VER=$(stack --numeric-version) | |
echo "STACK_VER=${STACK_VER}" >> "${GITHUB_ENV}" | |
- uses: actions/cache@v3 | |
name: Cache dependencies | |
id: cache | |
with: | |
path: ${{ steps.haskell-setup.outputs.stack-root }} | |
# A unique cache is used for each stack.yaml. | |
key: ${{ runner.os }}-stack-${{ env.STACK_VER }}-ghc-${{ matrix.ghc-ver }}-${{ hashFiles(format('stack-{0}.yaml', matrix.ghc-ver)) }} | |
# Let us restore caches from the same GHC version, at the risk of accumulating some cruft from older resolvers. | |
restore-keys: ${{ runner.os }}-stack-${{ env.STACK_VER }}-ghc-${{ matrix.ghc-ver }}- | |
- name: Install dependencies | |
if: ${{ !steps.cache.outputs.cache-hit }} | |
run: | | |
stack build ${ARGS} --only-dependencies | |
- name: Build fix-whitespace | |
run: | | |
stack build ${ARGS} | |
- name: Check the whitespace issue | |
run: | | |
stack exec ${ARGS} -- fix-whitespace --check | |
- name: Get fix-whitespace version | |
run: | | |
FIXW_EXE=$(stack path --local-install-root ${ARGS})/bin/fix-whitespace | |
FIXW_VERSION=$("${FIXW_EXE}" --version) | |
# Save env variables for the next steps | |
echo "FIXW_EXE=${FIXW_EXE}" >> "${GITHUB_ENV}" | |
echo "FIXW_VERSION=${FIXW_VERSION}" >> "${GITHUB_ENV}" | |
## Release | |
######################################################################## | |
# - name: Source tarball creation | |
# # Conditional to ensure this deployment is only run once per action. | |
# if: >- | |
# startsWith(github.ref, 'refs/tags/v') | |
# && matrix.ghc-ver == '9.6.2' | |
# run: | | |
# DIST_TGZ=$(cabal sdist | tail -1) | |
# echo "DIST_TGZ=${DIST_TGZ}" >> "${GITHUB_ENV}" | |
# - name: Source tarball release | |
# if: >- | |
# startsWith(github.ref, 'refs/tags/v') | |
# && matrix.ghc-ver == '9.6.2' | |
# # uses: softprops/action-gh-release@v1 | |
# # with: | |
# # draft: true | |
# # prerelease: true | |
# # files: | | |
# # ${{ env.DIST_TGZ }} | |
# uses: actions/upload-release-asset@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ github.token }} | |
# with: | |
# upload_url: ${{ needs.create_release.outputs.upload_url }} | |
# asset_path: ${{ env.DIST_TGZ }} | |
# asset_name: ${{ env.DIST_TGZ }} | |
# asset_content_type: application/octet-stream | |
- name: Linux release preparation | |
if: >- | |
startsWith(github.ref, 'refs/tags/v') | |
&& runner.os == 'Linux' | |
&& matrix.ghc-ver == '9.6.2' | |
run: | | |
FIXW_BIN=fix-whitespace-${FIXW_VERSION}-linux.binary | |
cp -p "${FIXW_EXE}" "${FIXW_BIN}" | |
# Save env variables for the next step | |
echo "FIXW_BIN=${FIXW_BIN}" >> "${GITHUB_ENV}" | |
# - name: Linux release | |
# if: >- | |
# startsWith(github.ref, 'refs/tags/v') | |
# && runner.os == 'Linux' | |
# && matrix.ghc-ver == '9.6.2' | |
# # uses: softprops/action-gh-release@v1 | |
# # with: | |
# # draft: true | |
# # prerelease: true | |
# # files: | | |
# # ${{ env.FIXW_BIN }} | |
# uses: actions/upload-release-asset@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ github.token }} | |
# with: | |
# upload_url: ${{ needs.create_release.outputs.upload_url }} | |
# asset_path: ${{ env.FIXW_BIN }} | |
# asset_name: ${{ env.FIXW_BIN }} | |
# asset_content_type: application/octet-stream | |
- name: Mac release preparation | |
if: >- | |
startsWith(github.ref, 'refs/tags/v') | |
&& runner.os == 'macOS' | |
run: | | |
FIXW_BIN=fix-whitespace-${FIXW_VERSION}-mac.binary | |
# Raw Mac binary | |
cp -p "${FIXW_EXE}" "${FIXW_BIN}" | |
# Save env variables for the next step | |
echo "FIXW_BIN=${FIXW_BIN}" >> "${GITHUB_ENV}" | |
# - name: Mac release | |
# if: >- | |
# startsWith(github.ref, 'refs/tags/v') | |
# && runner.os == 'macOS' | |
# # uses: softprops/action-gh-release@v1 | |
# # with: | |
# # draft: true | |
# # prerelease: true | |
# # files: | | |
# # ${{ env.FIXW_BIN }} | |
# uses: actions/upload-release-asset@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ github.token }} | |
# with: | |
# upload_url: ${{ needs.create_release.outputs.upload_url }} | |
# asset_path: ${{ env.FIXW_BIN }} | |
# asset_name: ${{ env.FIXW_BIN }} | |
# asset_content_type: application/octet-stream | |
- name: Windows release preparation | |
if: >- | |
startsWith(github.ref, 'refs/tags/v') | |
&& runner.os == 'Windows' | |
shell: bash | |
run: | | |
FIXW_BIN=fix-whitespace-${FIXW_VERSION}.exe | |
cp -p "${FIXW_EXE}.exe" "${FIXW_BIN}" | |
# Save env variables for the next step | |
echo "FIXW_BIN=${FIXW_BIN}" >> "${GITHUB_ENV}" | |
# - name: Windows release | |
# if: >- | |
# startsWith(github.ref, 'refs/tags/v') | |
# && runner.os == 'Windows' | |
# uses: actions/upload-release-asset@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ github.token }} | |
# with: | |
# upload_url: ${{ needs.create_release.outputs.upload_url }} | |
# asset_path: ${{ env.FIXW_BIN }} | |
# asset_name: ${{ env.FIXW_BIN }} | |
# asset_content_type: application/octet-stream | |
# # uses: softprops/action-gh-release@v1 | |
# # with: | |
# # draft: true | |
# # prerelease: true | |
# # files: | | |
# # ${{ env.FIXW_VER_EXE }} | |
# - name: Upload binary | |
# if: >- | |
# startsWith(github.ref, 'refs/tags/v') | |
# && (matrix.ghc-ver == '9.6.2' || runner.os != 'Linux') | |
# uses: actions/upload-release-asset@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ github.token }} | |
# with: | |
# upload_url: ${{ needs.create_release.outputs.upload_url }} | |
# asset_path: ${{ env.FIXW_BIN }} | |
# asset_name: ${{ env.FIXW_BIN }} | |
# asset_content_type: application/octet-stream | |
- name: Upload binary | |
if: >- | |
startsWith(github.ref, 'refs/tags/v') | |
&& (matrix.ghc-ver == '9.6.2' || runner.os != 'Linux') | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
gh release upload ${{ github.ref }} "${{ env.FIXW_BIN }}" --clobber |