|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Release Job |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout Repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + # Extract version from the tag. For example, if GITHUB_REF is "refs/tags/v0.3.1.0" |
| 17 | + # this step will set the output "version" to "0.3.1.0". |
| 18 | + - name: Extract Version |
| 19 | + id: extract_version |
| 20 | + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 21 | + |
| 22 | + - name: Setup Haskell (Cabal) |
| 23 | + uses: haskell-actions/setup@v2 |
| 24 | + with: |
| 25 | + ghc-version: '9.8.4' |
| 26 | + |
| 27 | + - name: Cabal Check |
| 28 | + run: cabal check |
| 29 | + |
| 30 | + - name: Generate Haddock Documentation |
| 31 | + run: cabal haddock --haddock-html --haddock-hoogle --builddir=dist/haddock |
| 32 | + |
| 33 | + - name: Build Source Distribution (Tarball for Hackage) |
| 34 | + run: cabal sdist |
| 35 | + |
| 36 | + - name: Zip Haddock Documentation |
| 37 | + run: | |
| 38 | + cd dist/haddock/build/x86_64-linux/ghc-9.8.4/socket-unix-${{ steps.extract_version.outputs.version }}/doc/html/socket-unix |
| 39 | + # Change directory into the docs folder and zip its contents into haddock.zip at the repository root. |
| 40 | + zip -r ../../../../../../haddock.zip . |
| 41 | +
|
| 42 | + - name: Create GitHub Release and Upload Assets |
| 43 | + uses: ncipollo/release-action@v1 |
| 44 | + with: |
| 45 | + tag: ${{ github.ref }} |
| 46 | + name: Release ${{ github.ref }} |
| 47 | + artifacts: | |
| 48 | + dist-newstyle/sdist/*.tar.gz |
| 49 | + haddock.zip |
| 50 | +
|
| 51 | + - name: Deploy Haddock Documentation to GitHub Pages |
| 52 | + uses: peaceiris/actions-gh-pages@v3 |
| 53 | + with: |
| 54 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + publish_branch: gh-pages |
| 56 | + publish_dir: dist/haddock/build/x86_64-linux/ghc-9.8.4/socket-unix-${{ steps.extract_version.outputs.version }}/doc/html/socket-unix |
| 57 | + destination_dir: ${{ github.ref_name }} |
| 58 | + |
| 59 | + |
| 60 | + update-index: |
| 61 | + name: Update Documentation Index |
| 62 | + runs-on: ubuntu-latest |
| 63 | + needs: release |
| 64 | + steps: |
| 65 | + - name: Checkout gh-pages branch |
| 66 | + uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + ref: gh-pages |
| 69 | + - name: Set up Git user |
| 70 | + run: | |
| 71 | + git config user.name "github-actions[bot]" |
| 72 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 73 | + - name: Update Documentation Index |
| 74 | + run: | |
| 75 | + chmod +x ./scripts/generate-index.sh |
| 76 | + ./scripts/generate-index.sh |
| 77 | + git add index.html |
| 78 | + if ! git diff --cached --exit-code; then |
| 79 | + git commit -m "Update documentation index" |
| 80 | + git push origin gh-pages |
| 81 | + else |
| 82 | + echo "No changes to index.html" |
| 83 | + fi |
0 commit comments