diff --git a/.github/workflows/haskell-release.yml b/.github/workflows/haskell-release.yml index c21de00f8..f7c84932e 100644 --- a/.github/workflows/haskell-release.yml +++ b/.github/workflows/haskell-release.yml @@ -10,178 +10,142 @@ on: - "[0-9]+.[0-9]+.[0-9]+.[0-9]+*" jobs: - create_release: - name: Create Github Release - runs-on: ubuntu-latest + build-binaries: + name: Haskell-Release - ${{ matrix.os }} - ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 points to x64 based OS and macos-latest points to arm based OS + os: + - ubuntu-latest + - macos-latest + - macos-13 + cabal: + - 3.12.1.0 + ghc: + - 9.8.2 + steps: - name: Check out code uses: actions/checkout@v4 - - name: Zip data directory - run: | - zip -r swarm-data.zip ./data || { echo "Unable to create a zip archive."; exit 1; } - - - name: Create Release - id: create_release - uses: softprops/action-gh-release@v1 - with: - files: | - LICENSE - swarm-data.zip - - - name: Output Release URL File - run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt - - - name: Save Release URL File for publish - uses: actions/upload-artifact@v4 - with: - name: release_url - path: release_url.txt - - build_artifact: - needs: [create_release] - name: Haskell-Release - ${{ matrix.os }} - ${{ matrix.compiler }} - runs-on: ubuntu-20.04 - container: - # It might be good idea to use older runner for building binary: - # on latest runners like fedora, it would link symbols in newer - # system libraries, so users could not run it on older OSes - image: buildpack-deps:jammy - strategy: - matrix: - include: - - compiler: ghc-9.8.2 - compilerKind: ghc - compilerVersion: 9.8.2 - setup-method: ghcup - steps: - - name: apt - run: | - apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 - mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.30.0/x86_64-linux-ghcup-0.1.30.0 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) - "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - - name: Set PATH and environment variables - run: | - echo "$HOME/.cabal/bin" >> $GITHUB_PATH - echo "LANG=C.UTF-8" >> "$GITHUB_ENV" - echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" - echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" - HCDIR=/opt/$HCKIND/$HCVER - HC=$HOME/.ghcup/bin/$HCKIND-$HCVER - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" - echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') - echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" - echo "HEADHACKAGE=false" >> "$GITHUB_ENV" - echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - - name: env - run: | - env - - name: write cabal config - run: | - mkdir -p $CABAL_DIR - cat >> $CABAL_CONFIG <> $CABAL_CONFIG <> "$GITHUB_ENV" - - name: Load Release URL File from release job - uses: actions/download-artifact@v4 - with: - name: release_url + - if: matrix.os == 'ubuntu-latest' + name: Set binary OS name on Ubuntu + run: echo BINARY_OS=${{ runner.os }} >> "$GITHUB_ENV" - - name: Get Release File Name & Upload URL - id: get_release_info - run: | - echo "upload_url=$(cat release_url.txt)" >> "$GITHUB_OUTPUT" + - if: (matrix.os == 'macos-13') || (matrix.os == 'macos-latest') + name: Set binary OS name on Macos + run: echo BINARY_OS="Darwin" >> "$GITHUB_ENV" - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release_info.outputs.upload_url }} - asset_path: ${{ env.BINARY_PATH }} - asset_name: swarm-${{ runner.os }} - asset_content_type: application/octet-stream - - - name: Generate tarball for Hackage - run: $CABAL v2-sdist + - name: Set binary Arch name + run: echo ARCH="x86_64" >> "$GITHUB_ENV" - # - name: Generate documentation for Hackage - # # The hackage-server attempts to build documentation for library packages, but this can fail. - # # If it does we can do it ourselves - # run: cabal v2-haddock --builddir=docs --haddock-for-hackage --enable-doc + - if: matrix.os == 'macos-latest' + name: Set binary ARCH name for apple silicon + run: echo ARCH="arm64" >> "$GITHUB_ENV" - - uses: haskell-actions/hackage-publish@v1 + - name: Upload executables + uses: actions/upload-artifact@v4 with: - hackageToken: "${{ secrets.HACKAGE_AUTH_TOKEN }}" - packagesPath: dist-newstyle/sdist - # docsPath: docs - publish: true + name: swarm-${{ env.BINARY_OS }}-${{env.ARCH}} + path: ${{ env.BINARY_PATH }} + retention-days: 3 + + create-release: + name: Create release + needs: [build-binaries] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Download Linux x86_64 + uses: actions/download-artifact@v4 + with: + name: swarm-Linux-x86_64 + path: artifacts/swarm-Linux-x86_64 + + - name: Download executable for Macos x86_64 + uses: actions/download-artifact@v4 + with: + name: swarm-Darwin-x86_64 + path: artifacts/swarm-Darwin-x86_64 + + - name: Download executable for arm64 Macos + uses: actions/download-artifact@v4 + with: + name: swarm-Darwin-arm64 + path: artifacts/swarm-Darwin-arm64 + + - name: Download Swarm data + uses: actions/download-artifact@v4 + with: + name: swarm-data.zip + path: artifacts/swarm-Darwin-arm64 + + - name: Rename executables + run: | + mv artifacts/swarm-Linux-x86_64/swarm swarm-Linux-x86_64 + mv artifacts/swarm-Darwin-x86_64/swarm swarm-Darwin-x86_64 + mv artifacts/swarm-Darwin-arm64/swarm swarm-Darwin-arm64 + + - name: Zip data directory + run: zip -r swarm-data.zip ./data || { echo "Unable to create a zip archive."; exit 1; } + + - name: Upload Release Asset + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: swarm + draft: false + prerelease: false + files: | + swarm-Linux-x86_64 + swarm-Darwin-x86_64 + swarm-Darwin-arm64 + LICENSE + swarm-data.zip + + # - name: Generate documentation for Hackage + # # The hackage-server attempts to build documentation for library packages, but this can fail. + # # If it does we can do it ourselves + # run: cabal v2-haddock --builddir=docs --haddock-for-hackage --enable-doc + + - uses: haskell-actions/hackage-publish@v1 + with: + hackageToken: "${{ secrets.HACKAGE_AUTH_TOKEN }}" + packagesPath: dist-newstyle/sdist + # docsPath: docs + publish: true