Skip to content

Commit e593b4a

Browse files
authored
CI: use actions create-release and upload-release-asset (#41)
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.
1 parent ffd3511 commit e593b4a

File tree

6 files changed

+167
-67
lines changed

6 files changed

+167
-67
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#
99
# For more information, see https://github.com/haskell-CI/haskell-ci
1010
#
11-
# version: 0.15.20220920
11+
# version: 0.15.202211107
1212
#
13-
# REGENDATA ("0.15.20220920",["github","fix-whitespace.cabal"])
13+
# REGENDATA ("0.15.202211107",["github","fix-whitespace.cabal"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -34,14 +34,14 @@ jobs:
3434
strategy:
3535
matrix:
3636
include:
37-
- compiler: ghc-9.4.2
37+
- compiler: ghc-9.4.3
3838
compilerKind: ghc
39-
compilerVersion: 9.4.2
39+
compilerVersion: 9.4.3
4040
setup-method: ghcup
4141
allow-failure: false
42-
- compiler: ghc-9.2.4
42+
- compiler: ghc-9.2.5
4343
compilerKind: ghc
44-
compilerVersion: 9.2.4
44+
compilerVersion: 9.2.5
4545
setup-method: ghcup
4646
allow-failure: false
4747
- compiler: ghc-9.0.2
@@ -181,7 +181,7 @@ jobs:
181181
chmod a+x $HOME/.cabal/bin/cabal-plan
182182
cabal-plan --version
183183
- name: checkout
184-
uses: actions/checkout@v2
184+
uses: actions/checkout@v3
185185
with:
186186
path: source
187187
- name: initial cabal.project for sdist
@@ -217,7 +217,7 @@ jobs:
217217
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
218218
cabal-plan
219219
- name: cache
220-
uses: actions/cache@v2
220+
uses: actions/cache@v3
221221
with:
222222
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
223223
path: ~/.cabal/store

.github/workflows/stack.yml

Lines changed: 148 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,67 @@ permissions:
1818
contents: write
1919

2020
jobs:
21-
check:
21+
22+
## Release preparation
23+
##########################################################################
24+
25+
# From: https://github.com/RobLoach/node-raylib/blob/aca2956e9ed283e5e91b1c8f08fafd943b5d6344/.github/workflows/release.yml
26+
create_release:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
upload_url: ${{ steps.create_release.outputs.upload_url }}
30+
steps:
31+
32+
- uses: actions/checkout@v3
33+
if: startsWith(github.ref, 'refs/tags/v')
34+
35+
- name: Create release
36+
if: startsWith(github.ref, 'refs/tags/v')
37+
id: create_release
38+
uses: actions/create-release@v1
39+
with:
40+
draft: false
41+
prerelease: false
42+
release_name: fix-whitespace ${{ github.ref }}
43+
tag_name: ${{ github.ref }}
44+
# body: fix-whitespace binary release created from ${{ github.ref }}
45+
env:
46+
GITHUB_TOKEN: ${{ github.token }}
47+
48+
- name: Source tarball creation.
49+
# Conditional to ensure this deployment is only run once per action.
50+
if: startsWith(github.ref, 'refs/tags/v')
51+
run: |
52+
cabal sdist
53+
export DIST_TGZ_PATH=$(cabal sdist | tail -1)
54+
export DIST_TGZ_NAME=$(basename "${DIST_TGZ_PATH}")
55+
echo "DIST_TGZ_PATH=${DIST_TGZ_PATH}" >> ${GITHUB_ENV}
56+
echo "DIST_TGZ_NAME=${DIST_TGZ_NAME}" >> ${GITHUB_ENV}
57+
58+
- name: Source tarball release.
59+
if: startsWith(github.ref, 'refs/tags/v')
60+
uses: actions/upload-release-asset@v1
61+
env:
62+
GITHUB_TOKEN: ${{ github.token }}
63+
with:
64+
upload_url: ${{ steps.create_release.outputs.upload_url }}
65+
asset_path: ${{ env.DIST_TGZ_PATH }}
66+
asset_name: ${{ env.DIST_TGZ_NAME }}
67+
asset_content_type: application/octet-stream
68+
69+
70+
build:
2271
runs-on: ${{ matrix.os }}
72+
needs: create_release
2373
strategy:
2474
matrix:
2575
os: [ubuntu-20.04]
26-
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]
76+
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]
2777
include:
2878
- os: windows-2022
2979
ghc-ver: 9.2.4
3080
- os: macos-11
31-
ghc-ver: 9.2.4
81+
ghc-ver: 9.2.5
3282
fail-fast: false
3383

3484
env:
@@ -90,49 +140,65 @@ jobs:
90140
## Release
91141
########################################################################
92142

93-
- name: Source tarball creation.
94-
# Conditional to ensure this deployment is only run once per action.
95-
if: >-
96-
startsWith(github.ref, 'refs/tags/v')
97-
&& matrix.ghc-ver == '9.2.4'
98-
run: |
99-
export DIST_TGZ=$(cabal sdist source | tail -1)
100-
echo "DIST_TGZ=${DIST_TGZ}" >> ${GITHUB_ENV}
143+
# - name: Source tarball creation.
144+
# # Conditional to ensure this deployment is only run once per action.
145+
# if: >-
146+
# startsWith(github.ref, 'refs/tags/v')
147+
# && matrix.ghc-ver == '9.2.5'
148+
# run: |
149+
# export DIST_TGZ=$(cabal sdist | tail -1)
150+
# echo "DIST_TGZ=${DIST_TGZ}" >> ${GITHUB_ENV}
101151

102-
- name: Source tarball release.
103-
if: >-
104-
startsWith(github.ref, 'refs/tags/v')
105-
&& matrix.ghc-ver == '9.2.4'
106-
uses: softprops/action-gh-release@v1
107-
with:
108-
draft: true
109-
prerelease: true
110-
files: |
111-
${{ env.DIST_TGZ }}
152+
# - name: Source tarball release.
153+
# if: >-
154+
# startsWith(github.ref, 'refs/tags/v')
155+
# && matrix.ghc-ver == '9.2.5'
156+
# # uses: softprops/action-gh-release@v1
157+
# # with:
158+
# # draft: true
159+
# # prerelease: true
160+
# # files: |
161+
# # ${{ env.DIST_TGZ }}
162+
# uses: actions/upload-release-asset@v1
163+
# env:
164+
# GITHUB_TOKEN: ${{ github.token }}
165+
# with:
166+
# upload_url: ${{ needs.create_release.outputs.upload_url }}
167+
# asset_path: ${{ env.DIST_TGZ }}
168+
# asset_name: ${{ env.DIST_TGZ }}
169+
# asset_content_type: application/octet-stream
112170

113171

114172
- name: Linux release preparation.
115173
if: >-
116174
startsWith(github.ref, 'refs/tags/v')
117175
&& runner.os == 'Linux'
118-
&& matrix.ghc-ver == '9.2.4'
176+
&& matrix.ghc-ver == '9.2.5'
119177
run: |
120178
export FIXW_BIN=fix-whitespace-${FIXW_VERSION}-linux.binary
121179
cp -p ${FIXW_EXE} ${FIXW_BIN}
122180
# Save env variables for the next step
123181
echo "FIXW_BIN=${FIXW_BIN}" >> ${GITHUB_ENV}
124182
125-
- name: Linux release.
126-
if: >-
127-
startsWith(github.ref, 'refs/tags/v')
128-
&& runner.os == 'Linux'
129-
&& matrix.ghc-ver == '9.2.4'
130-
uses: softprops/action-gh-release@v1
131-
with:
132-
draft: true
133-
prerelease: true
134-
files: |
135-
${{ env.FIXW_BIN }}
183+
# - name: Linux release.
184+
# if: >-
185+
# startsWith(github.ref, 'refs/tags/v')
186+
# && runner.os == 'Linux'
187+
# && matrix.ghc-ver == '9.2.5'
188+
# # uses: softprops/action-gh-release@v1
189+
# # with:
190+
# # draft: true
191+
# # prerelease: true
192+
# # files: |
193+
# # ${{ env.FIXW_BIN }}
194+
# uses: actions/upload-release-asset@v1
195+
# env:
196+
# GITHUB_TOKEN: ${{ github.token }}
197+
# with:
198+
# upload_url: ${{ needs.create_release.outputs.upload_url }}
199+
# asset_path: ${{ env.FIXW_BIN }}
200+
# asset_name: ${{ env.FIXW_BIN }}
201+
# asset_content_type: application/octet-stream
136202

137203

138204
- name: Mac release preparation.
@@ -146,16 +212,24 @@ jobs:
146212
# Save env variables for the next step
147213
echo "FIXW_BIN=${FIXW_BIN}" >> ${GITHUB_ENV}
148214
149-
- name: Mac release.
150-
if: >-
151-
startsWith(github.ref, 'refs/tags/v')
152-
&& runner.os == 'macOS'
153-
uses: softprops/action-gh-release@v1
154-
with:
155-
draft: true
156-
prerelease: true
157-
files: |
158-
${{ env.FIXW_BIN }}
215+
# - name: Mac release.
216+
# if: >-
217+
# startsWith(github.ref, 'refs/tags/v')
218+
# && runner.os == 'macOS'
219+
# # uses: softprops/action-gh-release@v1
220+
# # with:
221+
# # draft: true
222+
# # prerelease: true
223+
# # files: |
224+
# # ${{ env.FIXW_BIN }}
225+
# uses: actions/upload-release-asset@v1
226+
# env:
227+
# GITHUB_TOKEN: ${{ github.token }}
228+
# with:
229+
# upload_url: ${{ needs.create_release.outputs.upload_url }}
230+
# asset_path: ${{ env.FIXW_BIN }}
231+
# asset_name: ${{ env.FIXW_BIN }}
232+
# asset_content_type: application/octet-stream
159233

160234

161235
- name: Windows release preparation.
@@ -164,18 +238,39 @@ jobs:
164238
&& runner.os == 'Windows'
165239
shell: bash
166240
run: |
167-
export FIXW_VER_EXE=fix-whitespace-${FIXW_VERSION}.exe
168-
cp -p ${FIXW_EXE}.exe ${FIXW_VER_EXE}
241+
export FIXW_BIN=fix-whitespace-${FIXW_VERSION}.exe
242+
cp -p ${FIXW_EXE}.exe ${FIXW_BIN}
169243
# Save env variables for the next step
170-
echo "FIXW_VER_EXE=${FIXW_VER_EXE}" >> ${GITHUB_ENV}
244+
echo "FIXW_BIN=${FIXW_BIN}" >> ${GITHUB_ENV}
171245
172-
- name: Windows release.
246+
# - name: Windows release.
247+
# if: >-
248+
# startsWith(github.ref, 'refs/tags/v')
249+
# && runner.os == 'Windows'
250+
# uses: actions/upload-release-asset@v1
251+
# env:
252+
# GITHUB_TOKEN: ${{ github.token }}
253+
# with:
254+
# upload_url: ${{ needs.create_release.outputs.upload_url }}
255+
# asset_path: ${{ env.FIXW_BIN }}
256+
# asset_name: ${{ env.FIXW_BIN }}
257+
# asset_content_type: application/octet-stream
258+
# # uses: softprops/action-gh-release@v1
259+
# # with:
260+
# # draft: true
261+
# # prerelease: true
262+
# # files: |
263+
# # ${{ env.FIXW_VER_EXE }}
264+
265+
- name: Upload binary.
173266
if: >-
174267
startsWith(github.ref, 'refs/tags/v')
175-
&& runner.os == 'Windows'
176-
uses: softprops/action-gh-release@v1
268+
&& (matrix.ghc-ver == '9.2.5' || !(runner.os == 'Linux'))
269+
uses: actions/upload-release-asset@v1
270+
env:
271+
GITHUB_TOKEN: ${{ github.token }}
177272
with:
178-
draft: true
179-
prerelease: true
180-
files: |
181-
${{ env.FIXW_VER_EXE }}
273+
upload_url: ${{ needs.create_release.outputs.upload_url }}
274+
asset_path: ${{ env.FIXW_BIN }}
275+
asset_name: ${{ env.FIXW_BIN }}
276+
asset_content_type: application/octet-stream

fix-whitespace.cabal

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ maintainer: Liang-Ting Chen <liang.ting.chen.tw@gmail.com>, Andreas Abel
1313
Category: Text
1414
Synopsis: Fixes whitespace issues.
1515
tested-with:
16-
GHC == 9.4.2
17-
GHC == 9.2.4
16+
GHC == 9.4.3
17+
GHC == 9.2.5
1818
GHC == 9.0.2
1919
GHC == 8.10.7
2020
GHC == 8.8.4
@@ -35,6 +35,8 @@ extra-source-files:
3535
stack-8.10.7.yaml
3636
stack-9.0.2.yaml
3737
stack-9.2.4.yaml
38+
stack-9.2.5.yaml
39+
stack-9.4.3.yaml
3840

3941
source-repository head
4042
type: git

stack-9.2.4.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
resolver: nightly-2022-08-19
1+
resolver: nightly-2022-11-12
22
compiler: ghc-9.2.4
33
compiler-check: match-exact
4-
5-
extra-deps:
6-
- filepattern-0.1.3

stack-9.2.5.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resolver: lts-20.1
2+
compiler: ghc-9.2.5
3+
compiler-check: match-exact

stack-9.4.3.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resolver: nightly-2022-11-26
2+
compiler: ghc-9.4.3
3+
compiler-check: match-exact

0 commit comments

Comments
 (0)