Switch releases to Github CI

This commit is contained in:
Julian Ospald 2022-10-20 20:37:50 +08:00
parent 787edc17af
commit c4912f010d
Signed by: hasufell
GPG Key ID: 3786C5262ECB4A3F
5 changed files with 179 additions and 88 deletions

15
.cirrus.yml Normal file
View File

@ -0,0 +1,15 @@
freebsd_instance:
image_family: freebsd-13-1
task:
env:
GHC_VER: 9.2.4
CABAL_VER: 3.6.2.0
ARTIFACT: "x86_64-portbld-freebsd-ghcup"
ARCH: 64
RUNNER_OS: FreeBSD
install_script: pkg install -y ghc hs-cabal-install git bash
script:
- bash .github/scripts/release.sh
binaries_artifacts:
path: "out/x86_64-portbld-freebsd-ghcup-*"

101
.github/scripts/release.sh vendored Normal file
View File

@ -0,0 +1,101 @@
#!/bin/sh
set -eux
mkdir -p "$HOME"/.local/bin
export PATH="$HOME/.local/bin:$PATH"
if [ "${RUNNER_OS}" = "macOS" ] ; then
if ! command -v brew ; then
git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.brew"
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"
brew update
fi
brew install git
fi
if [ "${RUNNER_OS}" = "Linux" ] ; then
apk add --no-cache \
curl \
gcc \
g++ \
binutils \
binutils-gold \
bsd-compat-headers \
gmp-dev \
ncurses-dev \
libffi-dev \
make \
xz \
tar \
perl \
bash \
git
apk add --no-cache \
zlib \
zlib-dev \
zlib-static \
bzip2 \
bzip2-dev \
bzip2-static \
gmp \
gmp-dev \
openssl-dev \
openssl-libs-static \
xz \
xz-dev \
ncurses-static
fi
if ! command -v ghcup ; then
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 sh
source ~/.ghcup/env
fi
if [ "${RUNNER_OS}" != "FreeBSD" ] ; then
ghcup install ghc --set --isolate="$HOME/.local" --force "$GHC_VER"
ghcup install cabal --isolate="$HOME/.local/bin" --force "$CABAL_VER"
ghc --version
cabal --version
fi
ecabal() {
cabal "$@"
}
git describe --all
# build
ecabal update
if [ "${RUNNER_OS}" = "Linux" ] ; then
if [ "${ARCH}" = "32" ] ; then
ecabal build -w "ghc-${GHC_VER}" --ghc-options='-split-sections -optl-static' -ftui
elif [ "${ARCH}" = "64" ] ; then
ecabal build -w "ghc-${GHC_VER}" --ghc-options='-split-sections -optl-static' -ftui
else
ecabal build -w "ghc-${GHC_VER}" -ftui
fi
elif [ "${RUNNER_OS}" = "FreeBSD" ] ; then
ecabal build -w "ghc-${GHC_VER}" --ghc-options='-split-sections' --constraint="zlib +bundled-c-zlib" --constraint="zip +disable-zstd" -ftui
elif [ "${RUNNER_OS}" = "Windows" ] ; then
ecabal build -w "ghc-${GHC_VER}" --constraint="zlib +bundled-c-zlib" --constraint="lzma +static"
else
ecabal build -w "ghc-${GHC_VER}" --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" -ftui
fi
mkdir out
binary=$(ecabal new-exec -w "ghc-${GHC_VER}" --verbose=0 --offline sh -- -c 'command -v ghcup')
ver=$("${binary}" --numeric-version)
if [ "${RUNNER_OS}" = "macOS" ] ; then
strip "${binary}"
else
if [ "${RUNNER_OS}" != "Windows" ] ; then
strip -s "${binary}"
fi
fi
cp "${binary}" "out/${ARTIFACT}-${ver}"

View File

@ -6,104 +6,80 @@ on:
- 'v*' - 'v*'
jobs: jobs:
draft_release: release-linux:
name: Draft Release name: Create Release x86_64
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release
- First Change
- Second Change
draft: true
prerelease: false
release-mac:
name: Create Release
needs: draft_release
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
CABAL_VER: 3.6.2.0
CACHE_VER: 1
MACOSX_DEPLOYMENT_TARGET: 10.13 MACOSX_DEPLOYMENT_TARGET: 10.13
strategy: strategy:
matrix: matrix:
os: include:
- macOS-10.15 - os: ubuntu-latest
ARTIFACT: "i386-linux-ghcup"
GHC_VER: 8.10.7
ARCH: 32
- os: ubuntu-latest
ARTIFACT: "x86_64-linux-ghcup"
GHC_VER: 8.10.7
ARCH: 64
- os: [self-hosted, macOS, aarch64]
ARTIFACT: "aarch64-apple-darwin-ghcup"
GHC_VER: 9.2.5
ARCH: 64
- os: macOS-10.15
ARTIFACT: "x86_64-apple-darwin-ghcup"
GHC_VER: 9.2.5
ARCH: 64
- os: windows-latest
ARTIFACT: "x86_64-mingw64-ghcup"
GHC_VER: 8.10.7
ARCH: 64
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v3
- uses: haskell/actions/setup@v1.2 - if: matrix.ARCH == '32' && runner.os == 'Linux'
name: Run release (32 bit linux)
uses: docker://i386/alpine:3.12
with: with:
ghc-version: 8.10.7 args: sh .github/scripts/release.sh
cabal-version: 3.6.2.0
- name: create ~/.local/bin
run: mkdir -p "$HOME/.local/bin"
shell: bash
- name: Add ~/.local/bin to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
shell: bash
- name: Update cabal cache
run: cabal update
shell: bash
- name: Install cabal dependencies
run: cabal build --only-dependencies --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" -ftui
shell: bash
- name: Build
run: cabal build --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" -ftui
shell: bash
- name: Install
run: cp "$(cabal list-bin exe:ghcup)" ~/.local/bin/ghcup
shell: bash
- name: Strip
run: strip ~/.local/bin/ghcup
shell: bash
- name: Run tests
run: cabal test --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" all
shell: bash
- name: Install git
run: brew install git
- name: set HOME
run: echo "HOME=$HOME" >> $GITHUB_ENV
shell: bash
- name: Set ASSET_PATH
run: echo "ASSET_PATH=$HOME/.local/bin/ghcup" >> $GITHUB_ENV
shell: bash
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ARTIFACT: ${{ matrix.ARTIFACT }}
ARCH: ${{ matrix.ARCH }}
GHC_VER: ${{ matrix.GHC_VER }}
- if: matrix.ARCH == '64' && runner.os == 'Linux'
name: Run release (64 bit linux)
uses: docker://alpine:3.12
with: with:
upload_url: ${{ needs.draft_release.outputs.upload_url }} args: sh .github/scripts/release.sh
asset_path: ${{ env.ASSET_PATH }} env:
asset_name: ghcup-${{ matrix.os }} ARTIFACT: ${{ matrix.ARTIFACT }}
asset_content_type: application/octet-stream ARCH: ${{ matrix.ARCH }}
GHC_VER: ${{ matrix.GHC_VER }}
- if: runner.os != 'Linux'
name: Run release (windows/mac)
run: bash .github/scripts/release.sh
env:
ARTIFACT: ${{ matrix.ARTIFACT }}
ARCH: ${{ matrix.ARCH }}
GHC_VER: ${{ matrix.GHC_VER }}
- if: always() - if: always()
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: plan.json name: artifacts
path: ./dist-newstyle/cache/plan.json path: |
./out/*
./dist-newstyle/cache/plan.json
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
./out/*
./dist-newstyle/cache/plan.json

View File

@ -5,7 +5,6 @@ optional-packages: ./vendored/*/*.cabal
optimization: 2 optimization: 2
package ghcup package ghcup
tests: True
flags: +tui flags: +tui
source-repository-package source-repository-package

View File

@ -174,7 +174,7 @@ library
build-depends: build-depends:
, bzlib , bzlib
, process ^>=1.6.11.0 , process ^>=1.6.11.0
, Win32 ^>=2.10 , Win32 >=2.10
else else
other-modules: other-modules: