Skip to content

Commit

Permalink
CI: use actions create-release and upload-release-asset (#41)
Browse files Browse the repository at this point in the history
Restructure binary release logic to avoid races:
1. Prepare release with `create-release` and propagate upload URL to following step.
2. Build binaries and upload them to the previously created URL.

Flaw in the ointment: action `upload-release-asset` is archived in favor of `softprops/action-gh-release`.  However, I don't see how to use the latter without an extra artifact upload/download step, which seems stupid.
  • Loading branch information
andreasabel authored Nov 26, 2022
1 parent ffd3511 commit e593b4a
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 67 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.15.20220920
# version: 0.15.202211107
#
# REGENDATA ("0.15.20220920",["github","fix-whitespace.cabal"])
# REGENDATA ("0.15.202211107",["github","fix-whitespace.cabal"])
#
name: Haskell-CI
on:
Expand All @@ -34,14 +34,14 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.4.2
- compiler: ghc-9.4.3
compilerKind: ghc
compilerVersion: 9.4.2
compilerVersion: 9.4.3
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.4
- compiler: ghc-9.2.5
compilerKind: ghc
compilerVersion: 9.2.4
compilerVersion: 9.2.5
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: source
- name: initial cabal.project for sdist
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
Expand Down
201 changes: 148 additions & 53 deletions .github/workflows/stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,67 @@ permissions:
contents: write

jobs:
check:

## Release preparation
##########################################################################

# From: https://github.com/RobLoach/node-raylib/blob/aca2956e9ed283e5e91b1c8f08fafd943b5d6344/.github/workflows/release.yml
create_release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:

- uses: actions/checkout@v3
if: startsWith(github.ref, 'refs/tags/v')

- name: Create release
if: startsWith(github.ref, 'refs/tags/v')
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.
# Conditional to ensure this deployment is only run once per action.
if: startsWith(github.ref, 'refs/tags/v')
run: |
cabal sdist
export DIST_TGZ_PATH=$(cabal sdist | tail -1)
export 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.
if: startsWith(github.ref, 'refs/tags/v')
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


build:
runs-on: ${{ matrix.os }}
needs: create_release
strategy:
matrix:
os: [ubuntu-20.04]
ghc-ver: [9.2.4, 9.0.2, 8.10.7, 8.8.4, 8.6.5, 8.4.4, 8.2.2, 8.0.2]
ghc-ver: [9.4.3, 9.2.5, 9.0.2, 8.10.7, 8.8.4, 8.6.5, 8.4.4, 8.2.2, 8.0.2]
include:
- os: windows-2022
ghc-ver: 9.2.4
- os: macos-11
ghc-ver: 9.2.4
ghc-ver: 9.2.5
fail-fast: false

env:
Expand Down Expand Up @@ -90,49 +140,65 @@ jobs:
## 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.2.4'
run: |
export DIST_TGZ=$(cabal sdist source | tail -1)
echo "DIST_TGZ=${DIST_TGZ}" >> ${GITHUB_ENV}
# - 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.2.5'
# run: |
# export 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.2.4'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.DIST_TGZ }}
# - name: Source tarball release.
# if: >-
# startsWith(github.ref, 'refs/tags/v')
# && matrix.ghc-ver == '9.2.5'
# # 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.2.4'
&& matrix.ghc-ver == '9.2.5'
run: |
export 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.2.4'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.FIXW_BIN }}
# - name: Linux release.
# if: >-
# startsWith(github.ref, 'refs/tags/v')
# && runner.os == 'Linux'
# && matrix.ghc-ver == '9.2.5'
# # 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.
Expand All @@ -146,16 +212,24 @@ jobs:
# 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 }}
# - 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.
Expand All @@ -164,18 +238,39 @@ jobs:
&& runner.os == 'Windows'
shell: bash
run: |
export FIXW_VER_EXE=fix-whitespace-${FIXW_VERSION}.exe
cp -p ${FIXW_EXE}.exe ${FIXW_VER_EXE}
export FIXW_BIN=fix-whitespace-${FIXW_VERSION}.exe
cp -p ${FIXW_EXE}.exe ${FIXW_BIN}
# Save env variables for the next step
echo "FIXW_VER_EXE=${FIXW_VER_EXE}" >> ${GITHUB_ENV}
echo "FIXW_BIN=${FIXW_BIN}" >> ${GITHUB_ENV}
- name: Windows release.
# - 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')
&& runner.os == 'Windows'
uses: softprops/action-gh-release@v1
&& (matrix.ghc-ver == '9.2.5' || !(runner.os == 'Linux'))
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
draft: true
prerelease: true
files: |
${{ env.FIXW_VER_EXE }}
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ env.FIXW_BIN }}
asset_name: ${{ env.FIXW_BIN }}
asset_content_type: application/octet-stream
6 changes: 4 additions & 2 deletions fix-whitespace.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ maintainer: Liang-Ting Chen <[email protected]>, Andreas Abel
Category: Text
Synopsis: Fixes whitespace issues.
tested-with:
GHC == 9.4.2
GHC == 9.2.4
GHC == 9.4.3
GHC == 9.2.5
GHC == 9.0.2
GHC == 8.10.7
GHC == 8.8.4
Expand All @@ -35,6 +35,8 @@ extra-source-files:
stack-8.10.7.yaml
stack-9.0.2.yaml
stack-9.2.4.yaml
stack-9.2.5.yaml
stack-9.4.3.yaml

source-repository head
type: git
Expand Down
5 changes: 1 addition & 4 deletions stack-9.2.4.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
resolver: nightly-2022-08-19
resolver: nightly-2022-11-12
compiler: ghc-9.2.4
compiler-check: match-exact

extra-deps:
- filepattern-0.1.3
3 changes: 3 additions & 0 deletions stack-9.2.5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resolver: lts-20.1
compiler: ghc-9.2.5
compiler-check: match-exact
3 changes: 3 additions & 0 deletions stack-9.4.3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resolver: nightly-2022-11-26
compiler: ghc-9.4.3
compiler-check: match-exact

0 comments on commit e593b4a

Please sign in to comment.