Skip to content

Commit

Permalink
chore: Publish to the real hackage index on release.
Browse files Browse the repository at this point in the history
On push, we publish candidates.
  • Loading branch information
iphydf committed Dec 25, 2021
1 parent ec85f9e commit b998d09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
- name: Install non-Haskell dependencies
run: if [ -f tools/prepare_third_party.sh ]; then tools/prepare_third_party.sh; fi
- name: Run tests
run: cabal test --enable-doc all
Expand Down
24 changes: 22 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: publish
on:
push:
branches: [master]
tags: ["*"]
release:
types: [published]

jobs:
hackage:
Expand Down Expand Up @@ -31,7 +32,8 @@ jobs:
- name: Build haddock documentation
run: cabal haddock --haddock-for-hackage --enable-doc

- name: Publish package to Hackage
- name: Publish package candidate to Hackage
if: ${{ github.event_name == 'push' }}
env:
API_TOKEN_HACKAGE: ${{ secrets.API_TOKEN_HACKAGE }}
run: |
Expand All @@ -47,3 +49,21 @@ jobs:
-H "Content-Encoding: gzip" \
--data-binary "@dist-newstyle/$PACKAGE-$VERSION-docs.tar.gz" \
"https://hackage.haskell.org/package/$PACKAGE-$VERSION/candidate/docs"
- name: Publish package to Hackage
if: ${{ github.event_name == 'release' }}
env:
API_TOKEN_HACKAGE: ${{ secrets.API_TOKEN_HACKAGE }}
run: |
PACKAGE=$(grep '^name:' *.cabal | awk '{print $2}')
VERSION=$(grep '^version:' *.cabal | awk '{print $2}')
cabal sdist
curl --header "Authorization: X-ApiKey $API_TOKEN_HACKAGE" \
-F "package=@dist-newstyle/sdist/$PACKAGE-$VERSION.tar.gz" \
"https://hackage.haskell.org/packages"
curl --header "Authorization: X-ApiKey $API_TOKEN_HACKAGE" \
-X PUT \
-H "Content-Type: application/x-tar" \
-H "Content-Encoding: gzip" \
--data-binary "@dist-newstyle/$PACKAGE-$VERSION-docs.tar.gz" \
"https://hackage.haskell.org/package/$PACKAGE-$VERSION/docs"

0 comments on commit b998d09

Please sign in to comment.