[CI] Try to add X64 macOS build #484
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Haskell CI | |
on: [push] | |
env: | |
PANDOC_VERSION: "3.5" | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
# macos-latest-large is amd64, while macos-latest is arm64 | |
os: [ubuntu-latest, macos-latest, macos-latest-large, windows-latest] | |
ghcver: ['9.6.6'] | |
runs-on: ${{ matrix.os }} | |
container: ${{ matrix.container }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: haskell-actions/setup@v2 | |
with: | |
ghc-version: ${{matrix.ghcver}} | |
- name: Cabal init | |
shell: pwsh | |
run: | | |
$store = Join-Path $pwd ".cabal-store" | |
New-Item -ItemType Directory -Force "$store" | |
cabal user-config init --force --augment="store-dir: $store" ` | |
--augment="install-method: copy" | |
- name: Cabal update | |
run: cabal v2-update | |
- name: Copy build config | |
shell: bash | |
run: cp misc/${{runner.os}}-${{runner.arch}}-build-cabal-config ./cabal.project | |
- name: Cabal configure | |
run: cabal v2-configure --constraint pandoc==${{ env.PANDOC_VERSION }} --constraint zip-archive'>='0.4.2.1 --enable-tests ${{matrix.extra-options}} | |
- uses: actions/cache@v2 | |
with: | |
path: .cabal-store | |
key: r2-${{runner.os}}-${{runner.arch}}-${{matrix.ghcver}}-${{ env.PANDOC_VERSION }}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}} | |
restore-keys: | | |
r2-${{runner.os}}-${{runner.arch}}-${{matrix.ghcver}}-${{ env.PANDOC_VERSION }}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}} | |
r2-${{runner.os}}-${{runner.arch}}-${{matrix.ghcver}}-${{ env.PANDOC_VERSION }}-${{hashFiles('pandoc-crossref.cabal')}} | |
r2-${{runner.os}}-${{runner.arch}}-${{matrix.ghcver}}-${{ env.PANDOC_VERSION }} | |
- shell: bash | |
run: | | |
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossref-* || true | |
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossr_-* || true | |
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pndc-crssrf-* || true | |
ls .cabal-store/ghc-${{matrix.ghcver}}/ || true | |
- name: Install dependencies | |
run: cabal v2-build --only-dependencies | |
- name: Build | |
run: cabal v2-build | |
- name: Run tests | |
run: cabal v2-test | |
- name: Install | |
shell: bash | |
run: | | |
mkdir pandoc-crossref-${{runner.os}}-${{runner.arch}} | |
export GIT_DIR="$PWD/.git" | |
cabal v2-install --installdir=$PWD/pandoc-crossref-${{runner.os}}-${{runner.arch}} | |
- name: Get Version | |
shell: bash | |
id: get_version | |
run: | | |
cd pandoc-crossref-${{runner.os}}-${{runner.arch}}/ | |
case "${{runner.os}}-${{runner.arch}}" in | |
Windows) | |
VERSION="$(./pandoc-crossref.exe --version)" | |
;; | |
*) chmod +x pandoc-crossref | |
VERSION="$(./pandoc-crossref --version)" | |
;; | |
esac | |
echo "$VERSION" | |
echo "$VERSION" > version.txt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{runner.os}}-${{runner.arch}}-build | |
path: pandoc-crossref-${{runner.os}}-${{runner.arch}} | |
- shell: bash | |
run: | | |
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossref-* | |
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossr_-* | |
rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pndc-crssrf-* | |
build-nix: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: cachix/install-nix-action@v20 | |
with: | |
github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
extra_nix_config: | | |
substituters = https://cache.nixos.org https://cache.iog.io | |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= | |
- uses: cachix/cachix-action@v12 | |
with: | |
name: pandoc-crossref | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- run: nix build | |
- run: nix build .#static | |
- run: | | |
cp -r result/bin/ pandoc-crossref-${{runner.os}}-${{runner.arch}} | |
chmod +w -R pandoc-crossref-${{runner.os}}-${{runner.arch}} | |
- name: Check pandoc version for static binary | |
run: | | |
./pandoc-crossref-${{runner.os}}-${{runner.arch}}/pandoc-crossref --version | grep -q 'Pandoc v${{ env.PANDOC_VERSION }}' | |
- run: nix run .#test | |
- run: nix run .#test-integrative | |
- run: nix develop -c echo ok | |
- name: Check pandoc version in shell | |
run: | | |
[ "$(nix develop -c pandoc --version | head -n1)" == "pandoc ${{ env.PANDOC_VERSION }}" ] | |
- name: Make manpage | |
run: | | |
nix develop -c pandoc -s -t man docs/index.md -o pandoc-crossref-${{runner.os}}-${{runner.arch}}/pandoc-crossref.1 | |
- name: Get Version | |
shell: bash | |
id: get_version | |
run: | | |
cd pandoc-crossref-${{runner.os}}-${{runner.arch}}/ | |
chmod +x pandoc-crossref | |
VERSION="$(./pandoc-crossref --version)" | |
echo "$VERSION" | |
echo "$VERSION" > version.txt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{runner.os}}-${{runner.arch}}-build-static | |
path: pandoc-crossref-${{runner.os}}-${{runner.arch}} | |
release: | |
needs: [build, build-nix] | |
runs-on: ubuntu-latest | |
container: alpine:3.15.0 | |
steps: | |
- run: | | |
echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories | |
apk add --update --no-cache p7zip hub upx bash tar xz | |
- uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v4 | |
- name: Repack assets | |
run: | | |
mkdir assets | |
chmod +x Linux-X64-build-static/pandoc-crossref | |
tar cJf assets/pandoc-crossref-Linux-X64-${{github.sha}}.tar.xz -C Linux-build-static pandoc-crossref pandoc-crossref.1 | |
chmod +x macOS-X64-build/pandoc-crossref | |
tar cJf assets/pandoc-crossref-macOS-X64-${{github.sha}}.tar.xz -C macOS-build pandoc-crossref | |
chmod +x macOS-ARM64-build/pandoc-crossref | |
tar cJf assets/pandoc-crossref-macOS-ARM64-${{github.sha}}.tar.xz -C macOS-build pandoc-crossref | |
cd Windows-X64-build | |
7z a ../assets/pandoc-crossref-Windows-X64-${{github.sha}}.7z pandoc-crossref.exe | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: release-assets | |
path: assets | |
- name: Generate description.md | |
if: startsWith(github.ref, 'refs/tags/v') | |
shell: bash | |
run: | | |
echo -n "" > description.md | |
for i in *-build; do | |
os="${i%-build}" | |
desc="$(cat $i/version.txt)" | |
echo "${os}: ${desc}" >> description.md | |
done | |
ver="${GITHUB_REF##*/v}" | |
echo "### Changelog" >> description.md | |
sed -rn '/^## *'"${ver//./\\.}"'/,/^##[^#]/ p' CHANGELOG.md | head -n-1 | tail -n+2 >> description.md | |
echo "description.md" | |
cat description.md | |
- name: Rename assets for release | |
if: startsWith(github.ref, 'refs/tags/v') | |
shell: bash | |
run: | | |
for i in assets/*; do | |
mv "$i" "${i/-${{github.sha}}/}" | |
done | |
- name: Create release | |
if: startsWith(github.ref, 'refs/tags/v') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: description.md | |
files: | | |
assets/* | |
fail_on_unmatched_files: true | |
- name: Extract branch name | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
shell: bash | |
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" | |
id: extract_branch | |
- name: Generate description outputs | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
shell: bash | |
run: | | |
for i in *-build; do | |
os="${i%-build}" | |
desc="$(cat $i/version.txt)" | |
echo ::set-output name=${os}::${desc} | |
done | |
id: description | |
- name: Upload "nightly" for Linux | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
uses: WebFreak001/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: https://uploads.github.com/repos/lierdakil/pandoc-crossref/releases/44009421/assets{?name,label} | |
release_id: 44009421 | |
asset_path: ./assets/pandoc-crossref-Linux-X64-${{github.sha}}.tar.xz | |
asset_name: pandoc-crossref-${{steps.extract_branch.outputs.branch}}-Linux-$$.tar.xz | |
asset_content_type: application/x-gtar | |
max_releases: 21 | |
- name: Upload "nightly" for macOS X64 | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
uses: WebFreak001/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: https://uploads.github.com/repos/lierdakil/pandoc-crossref/releases/44009421/assets{?name,label} | |
release_id: 44009421 | |
asset_path: ./assets/pandoc-crossref-macOS-X64-${{github.sha}}.tar.xz | |
asset_name: pandoc-crossref-${{steps.extract_branch.outputs.branch}}-macOS-X64-$$.tar.xz | |
asset_content_type: application/x-gtar | |
max_releases: 21 | |
- name: Upload "nightly" for macOS ARM64 | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
uses: WebFreak001/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: https://uploads.github.com/repos/lierdakil/pandoc-crossref/releases/44009421/assets{?name,label} | |
release_id: 44009421 | |
asset_path: ./assets/pandoc-crossref-macOS-ARM64-${{github.sha}}.tar.xz | |
asset_name: pandoc-crossref-${{steps.extract_branch.outputs.branch}}-macOS-ARM64-$$.tar.xz | |
asset_content_type: application/x-gtar | |
max_releases: 21 | |
- name: Upload "nightly" for Windows | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
uses: WebFreak001/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: https://uploads.github.com/repos/lierdakil/pandoc-crossref/releases/44009421/assets{?name,label} | |
release_id: 44009421 | |
asset_path: ./assets/pandoc-crossref-Windows-X64-${{github.sha}}.7z | |
asset_name: pandoc-crossref-${{steps.extract_branch.outputs.branch}}-Windows-$$.7z | |
asset_content_type: application/x-7z-compressed | |
max_releases: 21 | |
# TODO: where to put this? | |
# versionDescription: | | |
# Linux: ${{steps.description.outputs.Linux}} | |
# macOS: ${{steps.description.outputs.macOS}} | |
# Windows: ${{steps.description.outputs.Windows}} | |
build-stack: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: | | |
wget https://get.haskellstack.org/stable/linux-x86_64.tar.gz | |
tar zxf linux-x86_64.tar.gz | |
mv stack-*/stack ./ | |
chmod +x ./stack | |
- uses: actions/cache@v1 | |
with: | |
path: /home/runner/.stack | |
key: ${{ runner.os }}-stack | |
- name: Build and test | |
run: ./stack build --test | |
- name: Verify version | |
shell: bash | |
run: | | |
stack exec -- pandoc-crossref --version | grep -q 'Pandoc v${{ env.PANDOC_VERSION }}' |