Skip to content

Commit

Permalink
Merge pull request #784 from avh4/release/test-lamdera-community
Browse files Browse the repository at this point in the history
Configure MacOS ARM64 release builds
  • Loading branch information
avh4 authored Feb 10, 2023
2 parents d755e20 + 8307c65 commit c255a9f
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 38 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/Build release (lamdera-community).yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build release (lamdera-community)

on:
push:
tags: '*'
branches: 'release/*'

defaults:
run:
shell: bash

jobs:
build:
strategy:
fail-fast: false
matrix:
build:
- name: macOS-ARM64
runner: [ self-hosted, macOS, ARM64 ]
archive-label: macOS-arm64
ghc:
version: "9.2.5"
build-platform: aarch64-apple-darwin

name: release-${{ matrix.build.name }}
runs-on: ${{ matrix.build.runner }}

steps:
- name: Configure environment
run: |
git config --global core.autocrlf false
- uses: actions/checkout@v3
- name: Check platform
run: |
uname -m
arch
arch -arm64 uname -m
file ~/runner-setups/elm-format/_work/_tool/ghcup/0.1.19.0/arm64/ghcup
- name: Workaround for https://github.com/actions/checkout/issues/290
run: git fetch --tags --prune --unshallow --force
- name: Setup Haskell
id: setup-haskell
run: |
curl -o ghcup https://downloads.haskell.org/~ghcup/0.1.19.0/aarch64-apple-darwin-ghcup-0.1.19.0
chmod 0555 ./ghcup
file ./ghcup
export GHCUP_USE_XDG_DIRS=1
./ghcup list
export GHCUP_SKIP_UPDATE_CHECK=1
./ghcup unset ghc || true
./ghcup install ghc "${{ matrix.build.ghc.version }}"
./ghcup set ghc "${{ matrix.build.ghc.version }}"
./ghcup install cabal recommended
./ghcup set cabal recommended
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.local/bin:$PATH"
cabalStore="$GITHUB_WORKSPACE/_cabal-store"
~/.local/bin/cabal --store-dir="$cabalStore" v2-configure
echo "cabal-store=$cabalStore" >> "$GITHUB_OUTPUT"
- name: Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/20592#note_436353
run: |
echo "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" >> "$GITHUB_ENV"
cat "$GITHUB_ENV"
- name: Verify Haskell version
run: |
file "$(which cabal)"
cabal --version
ghc --version
ghc --print-build-platform
[[ $(ghc --numeric-version) == "${{ matrix.build.ghc.version }}" ]]
[[ $(ghc --print-build-platform) == "${{ matrix.build.ghc.build-platform }}" ]]
- uses: actions/cache@v3
name: Cache cabal-release-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cabal-release-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }}
- run: cabal v2-update
- run: ./build.sh -- dist-dependencies
- run: ./build.sh -- dist
- uses: actions/upload-artifact@v3
with:
name: elm-format-${{ github.sha }}-${{ matrix.build.archive-label }}
path: dist/
32 changes: 19 additions & 13 deletions .github/workflows/Build release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ jobs:
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- macOS-latest
build:
- name: windows
runner: windows-latest
archive-label: Windows
- name: macOS-x86
runner: macOS-latest
archive-label: macOS-x86

name: release-${{ matrix.os }}
runs-on: ${{ matrix.os }}
name: release-${{ matrix.build.name }}
runs-on: ${{ matrix.build.runner }}

steps:
- name: Configure environment
Expand Down Expand Up @@ -48,20 +52,22 @@ jobs:
cabal --version
ghc --version
[[ $(ghc --numeric-version) == 9.2.5 ]]
file "$(which cabal)"
file "$(which ghc)"
- uses: actions/cache@v3
name: Cache cabal-release-v1-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}
name: Cache cabal-release-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cabal-release-v1-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}
key: cabal-release-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }}
- run: cabal v2-update
- run: ./build.sh -- dist-dependencies
- run: ./build.sh -- dist
- name: Sign artifacts
run: |
for i in dist/*; do
gpg --verbose --local-user 1508E30E65C8C21F --output "$i".sig --detach-sig "$i"
done
# - name: Sign artifacts
# run: |
# for i in dist/*; do
# gpg --verbose --local-user 1508E30E65C8C21F --output "$i".sig --detach-sig "$i"
# done
- uses: actions/upload-artifact@v3
with:
name: elm-format-${{ github.sha }}-${{ runner.os }}
name: elm-format-${{ github.sha }}-${{ matrix.build.archive-label }}
path: dist/
11 changes: 2 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: CI

on:
push:
branches: '**'
pull_request:
branches:
- main
Expand Down Expand Up @@ -37,15 +35,10 @@ jobs:
with:
ghc-version: 9.2.5
- uses: actions/cache@v3
name: Cache cabal-v2-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}
name: Cache cabal-v2-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cabal-v2-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}
# - uses: actions/cache@v3
# name: Cache dist
# with:
# path: dist-newstyle
# key: dist-v1-${{ runner.os }}
key: cabal-v2-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }}
- run: cabal v2-update
- run: ./build.sh -- dependencies
- run: ./build.sh -- build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Snapshot release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ jobs:
ghc --version
[[ $(ghc --numeric-version) == 9.2.5 ]]
- uses: actions/cache@v3
name: Cache cabal-release-v1-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}
name: Cache cabal-release-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cabal-release-v1-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}
key: cabal-release-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }}
- run: cabal v2-update
- run: ./build.sh -- dist-dependencies
- run: ./build.sh -- dist
Expand Down
7 changes: 4 additions & 3 deletions Shakefiles/Haskell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ executable target projectName gitDescribe =
]
let buildOnCi =
[ Shakefiles.Platform.Windows
, Shakefiles.Platform.Mac
, Shakefiles.Platform.MacX86
, Shakefiles.Platform.MacArm64
]

forEach buildInDocker $ \target -> do
Expand All @@ -134,7 +135,7 @@ executable target projectName gitDescribe =
cmd_ "tar" "zcvf" out "-C" binDir binFile

forEach buildOnCi $ \target -> do
let githubRunnerOs = Shakefiles.Platform.githubRunnerOs target
let ciArchiveLabel = Shakefiles.Platform.ciArchiveLabel target
let zipExt = Shakefiles.Platform.zipFormatFor target

[ "_build" </> "github-ci" </> "unzipped" </> projectName ++ "-*-" ++ show target <.> zipExt,
Expand All @@ -143,7 +144,7 @@ executable target projectName gitDescribe =
let outDir = takeDirectory zip
let tag = drop (length projectName + 1) $ (reverse . drop (length (show target) + 1) . reverse) $ dropExtension $ takeFileName zip
StdoutTrim sha <- cmd "git" "rev-list" "-n1" ("tags/" ++ tag)
let ciArchive = "downloads" </> projectName ++ "-" ++ sha ++ "-" ++ githubRunnerOs <.> "zip"
let ciArchive = "downloads" </> projectName ++ "-" ++ sha ++ "-" ++ ciArchiveLabel <.> "zip"
need [ ciArchive ]
liftIO $ removeFiles "." [ zip, sig ]
cmd_ "unzip" "-o" "-d" outDir ciArchive
Expand Down
28 changes: 17 additions & 11 deletions Shakefiles/Platform.hs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
module Shakefiles.Platform (Platform(..), Shakefiles.Platform.all, platform, zipFormatFor, cabalInstallOs, githubRunnerOs, binExt) where
module Shakefiles.Platform (Platform(..), Shakefiles.Platform.all, platform, zipFormatFor, cabalInstallOs, ciArchiveLabel, binExt) where

import qualified System.Info


data Platform = Linux | Mac | Windows
data Platform = Linux | MacX86 | MacArm64 | Windows

instance Show Platform where
show Linux = "linux-x64"
show Mac = "mac-x64"
show MacX86 = "mac-x64"
show MacArm64 = "mac-arm64"
show Windows = "win-x64"


all :: [Platform]
all =
[ Linux
, Mac
, MacX86
, MacArm64
, Windows
]

Expand All @@ -23,8 +25,9 @@ platform :: Platform
platform =
case (System.Info.os, System.Info.arch) of
("linux", "x86_64") -> Linux
("darwin", "x86_64") -> Mac
("osx", "x86_64") -> Mac
("darwin", "x86_64") -> MacX86
("darwin", "aarch64") -> MacArm64
("osx", "x86_64") -> MacX86
("mingw32", "x86_64") -> Windows
("win32", "x86_64") -> Windows
other -> error ("unhandled operating system: " ++ show other)
Expand All @@ -33,22 +36,25 @@ platform =
zipFormatFor :: Platform -> String
zipFormatFor = \case
Linux -> "tgz"
Mac -> "tgz"
MacX86 -> "tgz"
MacArm64 -> "tgz"
Windows -> "zip"


binExt :: Platform -> String
binExt = \case
Linux -> ""
Mac -> ""
MacX86 -> ""
MacArm64 -> ""
Windows -> ".exe"


githubRunnerOs :: Platform -> String
githubRunnerOs = \case
ciArchiveLabel :: Platform -> String
ciArchiveLabel = \case
Linux -> "Linux"
Windows -> "Windows"
Mac -> "macOS"
MacX86 -> "macOS-x86"
MacArm64 -> "macOS-arm64"


cabalInstallOs :: String
Expand Down
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ in haskellPackages.shellFor {
niv
nixfmt
haskellPackages.haskell-language-server
unzip
];
}

0 comments on commit c255a9f

Please sign in to comment.