mirror of
https://github.com/swarm-game/swarm.git
synced 2024-10-05 20:19:09 +03:00
Generate github release executables for macos (#2046)
Changes include: - Generating executables for macos (x64 and arm) - Simplifications to GHC and cabal setup - Bump GH release action - Use `softprops/action-gh-release@v1` for uploading release assets instead of archived `actions/upload-release-asset@v1.0.1` Example release set: https://github.com/nitinprakash96/swarm-copy/releases/tag/0.8.2.8 And workflow: https://github.com/nitinprakash96/swarm-copy/actions/runs/10808335665
This commit is contained in:
parent
1edf55d244
commit
ab13170f4c
266
.github/workflows/haskell-release.yml
vendored
266
.github/workflows/haskell-release.yml
vendored
@ -10,178 +10,142 @@ on:
|
|||||||
- "[0-9]+.[0-9]+.[0-9]+.[0-9]+*"
|
- "[0-9]+.[0-9]+.[0-9]+.[0-9]+*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create_release:
|
build-binaries:
|
||||||
name: Create Github Release
|
name: Haskell-Release - ${{ matrix.os }} - ${{ matrix.ghc }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
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:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
# macos-13 points to x64 based OS and macos-latest points to arm based OS
|
||||||
- compiler: ghc-9.8.2
|
os:
|
||||||
compilerKind: ghc
|
- ubuntu-latest
|
||||||
compilerVersion: 9.8.2
|
- macos-latest
|
||||||
setup-method: ghcup
|
- macos-13
|
||||||
steps:
|
cabal:
|
||||||
- name: apt
|
- 3.12.1.0
|
||||||
run: |
|
ghc:
|
||||||
apt-get update
|
- 9.8.2
|
||||||
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 <<EOF
|
|
||||||
remote-build-reporting: anonymous
|
|
||||||
write-ghc-environment-files: never
|
|
||||||
remote-repo-cache: $CABAL_DIR/packages
|
|
||||||
logs-dir: $CABAL_DIR/logs
|
|
||||||
world-file: $CABAL_DIR/world
|
|
||||||
extra-prog-path: $CABAL_DIR/bin
|
|
||||||
symlink-bindir: $CABAL_DIR/bin
|
|
||||||
installdir: $CABAL_DIR/bin
|
|
||||||
build-summary: $CABAL_DIR/logs/build.log
|
|
||||||
store-dir: $CABAL_DIR/store
|
|
||||||
install-dirs user
|
|
||||||
prefix: $CABAL_DIR
|
|
||||||
repository hackage.haskell.org
|
|
||||||
url: http://hackage.haskell.org/
|
|
||||||
EOF
|
|
||||||
cat >> $CABAL_CONFIG <<EOF
|
|
||||||
program-default-options
|
|
||||||
ghc-options: $GHCJOBS +RTS -M3G -RTS
|
|
||||||
EOF
|
|
||||||
cat $CABAL_CONFIG
|
|
||||||
- name: versions
|
|
||||||
run: |
|
|
||||||
$HC --version || true
|
|
||||||
$HC --print-project-git-commit-id || true
|
|
||||||
$CABAL --version || true
|
|
||||||
- name: update cabal index
|
|
||||||
run: |
|
|
||||||
$CABAL v2-update -v
|
|
||||||
- name: cache (tools)
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-436fbe9d
|
|
||||||
path: ~/.haskell-ci-tools
|
|
||||||
|
|
||||||
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: haskell-actions/setup@v2
|
||||||
|
id: setup-haskell-cabal
|
||||||
|
name: Setup Haskell
|
||||||
|
with:
|
||||||
|
ghc-version: ${{ matrix.ghc }}
|
||||||
|
cabal-version: ${{ matrix.cabal }}
|
||||||
|
|
||||||
|
- name: Freeze
|
||||||
|
run: cabal freeze
|
||||||
|
|
||||||
- name: cache
|
- name: cache
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
|
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
|
||||||
path: ~/.cabal/store
|
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
|
||||||
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-
|
restore-keys: |
|
||||||
- name: install dependencies
|
${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
|
||||||
|
${{ matrix.os }}-${{ matrix.ghc }}-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
|
cabal v2-build --disable-tests --disable-benchmarks --dependencies-only -j2 all
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build binary
|
||||||
run: |
|
run: |
|
||||||
mkdir dist
|
mkdir dist
|
||||||
$CABAL v2-install $ARG_COMPILER exe:swarm --install-method=copy --overwrite-policy=always --installdir=dist
|
cabal v2-install exe:swarm --install-method=copy --overwrite-policy=always --installdir=dist
|
||||||
|
|
||||||
- name: Set binary path name
|
- name: Set binary path name
|
||||||
run: echo BINARY_PATH="./dist/swarm" >> "$GITHUB_ENV"
|
run: echo BINARY_PATH="./dist/swarm" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Load Release URL File from release job
|
- if: matrix.os == 'ubuntu-latest'
|
||||||
uses: actions/download-artifact@v4
|
name: Set binary OS name on Ubuntu
|
||||||
|
run: echo BINARY_OS=${{ runner.os }} >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- if: (matrix.os == 'macos-13') || (matrix.os == 'macos-latest')
|
||||||
|
name: Set binary OS name on Macos
|
||||||
|
run: echo BINARY_OS="Darwin" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Set binary Arch name
|
||||||
|
run: echo ARCH="x86_64" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- if: matrix.os == 'macos-latest'
|
||||||
|
name: Set binary ARCH name for apple silicon
|
||||||
|
run: echo ARCH="arm64" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Upload executables
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: release_url
|
name: swarm-${{ env.BINARY_OS }}-${{env.ARCH}}
|
||||||
|
path: ${{ env.BINARY_PATH }}
|
||||||
|
retention-days: 3
|
||||||
|
|
||||||
- name: Get Release File Name & Upload URL
|
create-release:
|
||||||
id: get_release_info
|
name: Create release
|
||||||
run: |
|
needs: [build-binaries]
|
||||||
echo "upload_url=$(cat release_url.txt)" >> "$GITHUB_OUTPUT"
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Upload Release Asset
|
- name: Download Linux x86_64
|
||||||
id: upload-release-asset
|
uses: actions/download-artifact@v4
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
with:
|
||||||
env:
|
name: swarm-Linux-x86_64
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
path: artifacts/swarm-Linux-x86_64
|
||||||
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
|
- name: Download executable for Macos x86_64
|
||||||
run: $CABAL v2-sdist
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: swarm-Darwin-x86_64
|
||||||
|
path: artifacts/swarm-Darwin-x86_64
|
||||||
|
|
||||||
# - name: Generate documentation for Hackage
|
- name: Download executable for arm64 Macos
|
||||||
# # The hackage-server attempts to build documentation for library packages, but this can fail.
|
uses: actions/download-artifact@v4
|
||||||
# # If it does we can do it ourselves
|
with:
|
||||||
# run: cabal v2-haddock --builddir=docs --haddock-for-hackage --enable-doc
|
name: swarm-Darwin-arm64
|
||||||
|
path: artifacts/swarm-Darwin-arm64
|
||||||
|
|
||||||
- uses: haskell-actions/hackage-publish@v1
|
- name: Download Swarm data
|
||||||
with:
|
uses: actions/download-artifact@v4
|
||||||
hackageToken: "${{ secrets.HACKAGE_AUTH_TOKEN }}"
|
with:
|
||||||
packagesPath: dist-newstyle/sdist
|
name: swarm-data.zip
|
||||||
# docsPath: docs
|
path: artifacts/swarm-Darwin-arm64
|
||||||
publish: true
|
|
||||||
|
- 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
|
||||||
|
Loading…
Reference in New Issue
Block a user