Skip to content

Commit 60cb25f

Browse files
chore: Update CI and fix static upload (#153)
* Update to newer versions * Inclue cabal packages in cache * attempt: static build * attempt: static build #2 * attempt: static build with ghc-musl in docker * fix: fix cabal file * attempt: use docker run * attempt: debug docker run * fix: remove files * attempt: compression with upx * attempt(fix): change permission * attempt(fix): retry * attempt(fix): change owner * feat: change binary file * modify: change order * modify: prepare everything for review * feat: include automatic release to Hackage * attempt: upload to hackage * fix: go back to ghc-8.10.7 * fix: drop char in sh * modify: Publish workflow * modify: Remove 8.10 from list * attempt: remove packages from cache and remove base-compat * fix: avoid api key leak
1 parent 810a216 commit 60cb25f

File tree

8 files changed

+138
-56
lines changed

8 files changed

+138
-56
lines changed
Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Test
1+
name: Build
22

33
on:
44
push:
@@ -9,29 +9,39 @@ on:
99
- opened
1010
- synchronize
1111

12+
concurrency:
13+
group: build-${{ github.ref }}
14+
cancel-in-progress: true
15+
1216
jobs:
1317
build-and-test:
1418
runs-on: ${{ matrix.os }}
1519
strategy:
1620
matrix:
17-
ghc: ["8.6.5", "8.8.3", "8.10.1", "9.0.1"]
21+
ghc: ["9.2", "9.0", "8.10"]
1822
os: [ubuntu-latest]
1923
include:
2024
- os: macos-latest
21-
ghc: "9.0.1"
25+
ghc: "9.2"
2226

2327
steps:
24-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
29+
2530
- name: Setup Haskell
2631
id: setup-haskell-cabal
27-
uses: haskell/actions/setup@v1
32+
uses: haskell/actions/setup@v2
2833
with:
2934
ghc-version: ${{ matrix.ghc }}
30-
cabal-version: "3.4"
31-
- run: cabal v2-update
32-
- run: cabal v2-freeze --enable-tests
35+
cabal-version: "3.6"
36+
37+
- name: Update dependencies with Hackage
38+
run: cabal update
39+
40+
- name: Build dependencies
41+
run: cabal freeze --enable-tests
42+
3343
- name: Cache dependencies and dist-newstyle
34-
uses: actions/cache@v2
44+
uses: actions/cache@v3
3545
with:
3646
path: |
3747
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
@@ -40,9 +50,12 @@ jobs:
4050
restore-keys: |
4151
dependencies-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
4252
dependencies-${{ runner.os }}-${{ matrix.ghc }}-
53+
4354
- name: Install dependencies
44-
run: cabal v2-install --only-dependencies
55+
run: cabal install --only-dependencies
56+
4557
- name: Build project
46-
run: cabal v2-build --enable-tests
58+
run: cabal build --enable-tests
59+
4760
- name: Run tests
48-
run: cabal v2-test --enable-tests
61+
run: cabal test --enable-tests

.github/workflows/draft.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release package to Github
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build-binary:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- uses: addnab/docker-run-action@v3
16+
with:
17+
image: utdemir/ghc-musl:v24-ghc922
18+
options: -v ${{ github.workspace }}:/mnt
19+
run: |
20+
cd /mnt
21+
sh build.static.sh
22+
23+
- name: Change owner before compression
24+
run: sudo chown $USER:$USER dotenv
25+
26+
- name: Compress binary
27+
uses: svenstaro/upx-action@v2
28+
with:
29+
file: dotenv
30+
args: --best --lzma
31+
strip: true
32+
33+
- name: Rename binary file
34+
run: cp dotenv dotenv-${{ github.ref_name }}-linux-x86_64-bin
35+
36+
- name: Create release with package assets
37+
uses: softprops/action-gh-release@v1
38+
with:
39+
body_path: CHANGELOG.md
40+
files: |
41+
dotenv-${{ github.ref_name }}-linux-x86_64-bin
42+
draft: true
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
name: Release
3+
4+
on:
5+
release:
6+
types:
7+
- published
8+
9+
concurrency:
10+
group: release-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
hackage:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Setup Haskell
20+
id: setup-haskell-cabal
21+
uses: haskell/actions/setup@v2
22+
with:
23+
# I faced the following issue with GHC-9.2 and and I managed to solved
24+
# it by going back to GHC-8.10.7 just to generate the docs:
25+
# - https://github.com/haskell/cabal/issues/8326
26+
ghc-version: "8.10.7"
27+
cabal-version: "3.6"
28+
29+
- name: Generate sdist
30+
run: cabal sdist
31+
32+
- name: Upload candidate package to Hackage
33+
env:
34+
HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }}
35+
run: |
36+
SDIST_PATH=$(ls dist-newstyle/sdist/dotenv-*.tar.gz)
37+
curl -X POST \
38+
-H 'Accept: text/plain' \
39+
-H "Authorization: X-ApiKey \"$HACKAGE_API_KEY\"" \
40+
--form "package=@${SDIST_PATH}" \
41+
"https://hackage.haskell.org/packages/candidates"
42+
43+
- name: Generate documentation
44+
run: cabal haddock --haddock-for-hackage --enable-documentation
45+
46+
- name: Upload Docs for candidateto Hackage
47+
env:
48+
HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }}
49+
run: |
50+
TAG_VERSION=${{ github.ref_name }}
51+
VERSION=${TAG_VERSION:1}
52+
DOCS_PATH=$(ls dist-newstyle/dotenv-*-docs.tar.gz)
53+
curl -X PUT \
54+
-H 'Content-Type: application/x-tar' \
55+
-H 'Content-Encoding: gzip' \
56+
-H "Authorization: X-ApiKey \"$HACKAGE_API_KEY\"" \
57+
--data-binary "@${DOCS_PATH}" \
58+
"https://hackage.haskell.org/package/dotenv-$VERSION/candidate/docs"

.github/workflows/release-gh.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ cabal.config
1717
*.hp
1818
.stack-work/
1919
.env
20+
dist-newstyle/

build.static.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
echo 'cabal update'
2+
cabal update
3+
echo 'build dependencies'
4+
cabal build --only-dependencies --enable-static
5+
echo 'build static executable'
6+
cabal build --enable-executable-static
7+
echo 'copy bin'
8+
cp $(cabal list-bin dotenv) dotenv
9+
echo 'finished'

dotenv.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ library
9090
, Configuration.Dotenv.Types
9191

9292
build-depends: base >= 4.9 && < 5.0
93-
, base-compat >= 0.4
9493
, directory
9594
, megaparsec >= 7.0.1 && < 10.0
9695
, containers

src/Configuration/Dotenv.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ import Configuration.Dotenv.Types (Config (..), ReaderT, ask,
2828
defaultConfig,
2929
liftReaderT, runReaderT)
3030
import Control.Exception (throw)
31-
import Control.Monad (when)
31+
import Control.Monad (unless, when)
3232
import Control.Monad.Catch
33-
import Control.Monad.Compat (unless)
3433
import Control.Monad.IO.Class (MonadIO (..))
3534
import Data.List (intersectBy, union,
3635
unionBy)

0 commit comments

Comments
 (0)