Skip to content

Commit

Permalink
Experiment with a release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewFluet committed Dec 27, 2024
1 parent 18add0c commit a7831ce
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 35 deletions.
38 changes: 12 additions & 26 deletions .github/actions/install-bootstrap-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ runs:
if [[ "${{ inputs.install-llvm }}" == "true" ]]; then sudo apt-get install llvm; fi
mkdir boot && cd boot
curl -O -L https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-linux-glibc2.31.tgz
tar xzf mlton-20210117-1.amd64-linux-glibc2.31.tgz --exclude='*/share'
mv mlton-20210117-1.amd64-linux-glibc2.31/* .
rmdir mlton-20210117-1.amd64-linux-glibc2.31
tar xzf mlton-20210117-1.amd64-linux-glibc2.31.tgz --exclude='*/share' --strip-components=1
rm mlton-20210117-1.amd64-linux-glibc2.31.tgz
- name: Install bootstrap dependencies (macos (amd64))
if: ${{ inputs.runner == 'macos-13' }}
Expand All @@ -31,39 +30,27 @@ runs:
# Install dependencies (macos (amd64))
# brew update
brew install -q gmp
echo "WITH_GMP_DIR=/usr/local" >> $GITHUB_ENV
echo "WITH_GMP_DIR=$(brew --prefix)" >> $GITHUB_ENV
if [[ "${{ inputs.install-llvm }}" == "true" ]]; then brew install llvm; echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH; fi
mkdir boot && cd boot
curl -O -L https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-darwin-19.6.gmp-homebrew.tgz
tar xzf mlton-20210117-1.amd64-darwin-19.6.gmp-homebrew.tgz --exclude='*/share'
mv mlton-20210117-1.amd64-darwin-19.6.gmp-homebrew/* .
rmdir mlton-20210117-1.amd64-darwin-19.6.gmp-homebrew
tar xzf mlton-20210117-1.amd64-darwin-19.6.gmp-homebrew.tgz --exclude='*/share' --strip-components=1
rm mlton-20210117-1.amd64-darwin-19.6.gmp-homebrew.tgz
- name: Install bootstrap dependencies (macos (arm64))
if: ${{ inputs.runner == 'macos-14' }}
if: ${{ (inputs.runner == 'macos-14') || (inputs.runner == 'macos-15') }}
shell: 'bash'
run: |
# Install dependencies (macos (arm64))
# brew update
brew install -q gmp
echo "WITH_GMP_DIR=/opt/homebrew" >> $GITHUB_ENV
if [[ "${{ matrix.codegen }}" == "llvm" ]]; then brew install llvm; echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH; fi
echo "WITH_GMP_DIR=$(brew --prefix)" >> $GITHUB_ENV
if [[ "${{ inputs.install-llvm }}" == "true" ]]; then brew install llvm; echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH; fi
mkdir boot && cd boot
curl -O -L https://projects.laas.fr/tina/software/mlton-20210117-1.arm64-darwin-21.6-gmp-static.tgz
tar xzf mlton-20210117-1.arm64-darwin-21.6-gmp-static.tgz --exclude='*/share'
mv mlton-20210117-1.arm64-darwin-21.6-gmp-static/* .
rmdir mlton-20210117-1.arm64-darwin-21.6-gmp-static
tar xzf mlton-20210117-1.arm64-darwin-21.6-gmp-static.tgz --exclude='*/share' --strip-components=1
rm mlton-20210117-1.arm64-darwin-21.6-gmp-static.tgz
- name: Install msys2 (windows)
if: ${{ startsWith(inputs.runner, 'windows') }}
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
base-devel
git
pactoys
- name: Install bootstrap dependencies (windows)
if: ${{ startsWith(inputs.runner, 'windows') }}
shell: 'msys2 {0}'
Expand All @@ -72,6 +59,5 @@ runs:
pacboy --noconfirm -S --needed gcc:p gmp-devel:
mkdir boot && cd boot
curl -O -L https://github.com/MLton/mlton/releases/download/on-20200817-release/mlton-20200817-amd64-mingw.tgz
tar xzf mlton-20200817-amd64-mingw.tgz --exclude='*/share'
mv mlton-20200817-amd64-mingw/* .
rmdir mlton-20200817-amd64-mingw
tar xzf mlton-20200817-amd64-mingw.tgz --exclude='*/share' --strip-components=1
rm mlton-20200817-amd64-mingw.tgz
120 changes: 120 additions & 0 deletions .github/workflows/binary-release-single.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Binary Release (single)

on:
workflow_dispatch:
inputs:
mlton-version:
required: true
type: string
runner:
required: true
type: string
checkout-ref:
required: false
type: string
old-mlton-runtime-args:
required: false
type: string
old-mlton-compile-args:
required: false
type: string
mlton-runtime-args:
required: false
type: string
mlton-compile-args:
required: false
type: string
mlton-binary-release-suffix:
required: false
type: string
workflow_call:
inputs:
mlton-version:
required: true
type: string
runner:
required: true
type: string
checkout-ref:
required: false
type: string
old-mlton-runtime-args:
required: false
type: string
old-mlton-compile-args:
required: false
type: string
mlton-runtime-args:
required: false
type: string
mlton-compile-args:
required: false
type: string
mlton-binary-release-suffix:
required: false
type: string

jobs:
binary-release-single:

runs-on: ${{ inputs.runner }}

defaults:
run:
shell: ${{ (startsWith(inputs.runner, 'windows') && 'msys2 {0}') || 'bash' }}

env:
MLTON_VERSION: ${{ inputs.mlton-version }}
RUNNER: ${{ inputs.runner }}

steps:
- name: Configure git
run: git config --global core.autocrlf false
shell: bash

- name: Install msys2 (windows)
if: ${{ startsWith(inputs.runner, 'windows') }}
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
base-devel
git
pactoys
pacboy: >-
github-cli:p
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: .github
ref: ${{ inputs.checkout-ref || 'master' }}

- name: Install bootstrap dependencies
uses: ./.github/actions/install-bootstrap-dependencies
with:
runner: ${{ inputs.runner }}
install-llvm: false

- name: Download and unpack source release
run: |
curl --fail -L https://github.com/${{ github.repository }}/releases/download/on-${{ inputs.mlton-version }}-release/mlton-${{ inputs.mlton-version }}.src.tgz | tar xz --strip-components=1
- name: Make binary release
run: |
# make binary-release
PATH=$(pwd)/boot/bin:$PATH \
make \
OLD_MLTON_RUNTIME_ARGS="ram-slop 0.90 ${{ inputs.old-mlton-runtime-args }}" \
OLD_MLTON_COMPILE_ARGS="${{ inputs.old-mlton-compile-args }}" \
MLTON_RUNTIME_ARGS="ram-slop 0.90 ${{ inputs.mlton-runtime-args }}" \
MLTON_COMPILE_ARGS="${{ inputs.mlton-compile-args }}" \
$( if [[ -n "$WITH_GMP_DIR" ]]; then echo "WITH_GMP_DIR=$WITH_GMP_DIR"; fi ) \
MLTON_BINARY_RELEASE_SUFFIX="${{ inputs.mlton-binary-release-suffix }}" \
binary-release
- name: Upload binary release
run: gh release upload on-${{ inputs.mlton-version }}-release mlton-${{ inputs.mlton-version }}*.tgz --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 changes: 66 additions & 0 deletions .github/workflows/binary-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Binary Release

on:
workflow_dispatch:
inputs:
mlton-version:
required: true
type: string
workflow_call:
inputs:
mlton-version:
required: true
type: string

jobs:
binary-release:
strategy:
fail-fast: false
matrix:
include:
- runner: "ubuntu-24.04"
mlton-binary-release-suffix: ".${RUNNER}_glibc$(cc -dM -E - <<< '#include <stdlib.h>' | sed -En 's;#define __GLIBC__ (.*);\\1;p').$(cc -dM -E - <<< '#include <stdlib.h>' | sed -En 's;#define __GLIBC_MINOR__ (.*);\\1;p')"
- runner: "ubuntu-24.04"
mlton-compile-args: "-link-opt -static"
mlton-binary-release-suffix: ".${RUNNER}_static"
- runner: "ubuntu-22.04"
mlton-binary-release-suffix: ".${RUNNER}_glibc$(cc -dM -E - <<< '#include <stdlib.h>' | sed -En 's;#define __GLIBC__ (.*);\\1;p').$(cc -dM -E - <<< '#include <stdlib.h>' | sed -En 's;#define __GLIBC_MINOR__ (.*);\\1;p')"
- runner: "ubuntu-22.04"
mlton-compile-args: "-link-opt -static"
mlton-binary-release-suffix: ".${RUNNER}_static"
- runner: "ubuntu-20.04"
mlton-binary-release-suffix: ".${RUNNER}_glibc$(cc -dM -E - <<< '#include <stdlib.h>' | sed -En 's;#define __GLIBC__ (.*);\\1;p').$(cc -dM -E - <<< '#include <stdlib.h>' | sed -En 's;#define __GLIBC_MINOR__ (.*);\\1;p')"
- runner: "ubuntu-20.04"
mlton-compile-args: "-link-opt -static"
mlton-binary-release-suffix: ".${RUNNER}_static"
- runner: "macos-13"
mlton-binary-release-suffix: ".${RUNNER}_gmp-homebrew"
- runner: "macos-13"
mlton-compile-args: "-gmp-link-opt $(brew --prefix)/lib/libgmp.a"
mlton-binary-release-suffix: ".${RUNNER}_gmp-static"
- runner: "macos-14"
mlton-binary-release-suffix: ".${RUNNER}_gmp-homebrew"
- runner: "macos-14"
mlton-compile-args: "-gmp-link-opt $(brew --prefix)/lib/libgmp.a"
mlton-binary-release-suffix: ".${RUNNER}_gmp-static"
- runner: "macos-15"
mlton-binary-release-suffix: ".${RUNNER}_gmp-homebrew"
- runner: "macos-15"
mlton-compile-args: "-gmp-link-opt $(brew --prefix)/lib/libgmp.a"
mlton-binary-release-suffix: ".${RUNNER}_gmp-static"
- runner: "windows-2022"
mlton-binary-release-suffix: ".${RUNNER}_${MSYSTEM}"
- runner: "windows-2022"
mlton-compile-args: "-link-opt -static"
mlton-binary-release-suffix: ".${RUNNER}_${MSYSTEM}_static"

uses: ./.github/workflows/binary-release-single.yml
with:
mlton-version: ${{ inputs.mlton-version }}
runner: ${{ matrix.runner }}
old-mlton-runtime-args: ${{ matrix.old-mlton-runtime-args }}
old-mlton-compile-args: ${{ matrix.old-mlton-compile-args }}
mlton-runtime-args: ${{ matrix.mlton-runtime-args }}
mlton-compile-args: ${{ matrix.mlton-compile-args }}
mlton-binary-release-suffix: ${{ matrix.mlton-binary-release-suffix }}
secrets: inherit
23 changes: 15 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ name: CI
on:
push:
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
Expand All @@ -30,21 +28,28 @@ jobs:
- cc: "gcc"
codegen: "llvm"

# The type of runner that the job will run on
runs-on: ${{ matrix.runner }}

defaults:
run:
shell: ${{ (startsWith(matrix.runner, 'windows') && 'msys2 {0}') || 'bash' }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Configure git (windows)
if: ${{ startsWith(matrix.runner, 'windows') }}
run: git config --global core.autocrlf false
- name: Configure git
shell: bash
run: git config --global core.autocrlf false

- name: Install msys2 (windows)
if: ${{ startsWith(matrix.runner, 'windows') }}
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
base-devel
git
pactoys
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -66,6 +71,7 @@ jobs:
- name: Build
run: |
# make all
PATH=$(pwd)/boot/bin:$PATH \
make \
CC=${{ matrix.cc }} \
Expand All @@ -87,6 +93,7 @@ jobs:
- name: Package
run: |
# make binary-release
make \
CC=${{ matrix.cc }} \
OLD_MLTON_RUNTIME_ARGS="ram-slop 0.90" \
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
mlton-version:
runs-on: ubuntu-24.04
outputs:
mlton-version: ${{ steps.mlton-version.outputs.mlton-version }}
steps:
- name: mlton-version
id: mlton-version
run: |
MLTON_VERSION=$( echo '${{ github.ref_name }}' | sed -En 's;on-([0-9]{8})-release;\1;p')
if [ -n "${MLTON_VERSION}" ]; then echo "mlton-version=${MLTON_VERSION}" >> "$GITHUB_OUTPUT"; else echo "Unable to determine MLTON_VERSION"; exit 1; fi
source-release:
needs: mlton-version
uses: ./.github/workflows/source-release.yml
with:
mlton-version: ${{ needs.mlton-version.outputs.mlton-version }}
secrets: inherit

binary-release:
needs: [mlton-version, source-release]
uses: ./.github/workflows/binary-release.yml
with:
mlton-version: ${{ needs.mlton-version.outputs.mlton-version }}
secrets: inherit
31 changes: 31 additions & 0 deletions .github/workflows/source-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Source Release

on:
workflow_dispatch:
inputs:
mlton-version:
required: true
type: string
workflow_call:
inputs:
mlton-version:
required: true
type: string

jobs:
source-release:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: on-${{ inputs.mlton-version }}-release
fetch-depth: 0
- name: Install guide dependencies
uses: ./.github/actions/install-guide-dependencies
- name: Make source release
run: make MLTON_VERSION="${{ inputs.mlton-version }}" source-release
- name: Upload source release
run: gh release upload on-${{ inputs.mlton-version }}-release mlton-${{ inputs.mlton-version }}.src.tgz --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ source-release:
$(MAKE) MLTON_VERSION=$(MLTON_VERSION) version
$(MAKE) -C doc/guide
$(TAR) cvzf ./mlton-$(MLTON_VERSION).src.tgz \
--exclude .git/ --exclude package/ --exclude mlton-*.tgz \
--exclude .git/ --exclude .github/ --exclude package/ --exclude mlton-*.tgz \
--transform "s@^@mlton-$(MLTON_VERSION)/@S" \
*

Expand Down

0 comments on commit a7831ce

Please sign in to comment.