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 23, 2024
1 parent 18add0c commit c777631
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 31 deletions.
32 changes: 9 additions & 23 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 @@ -35,9 +34,8 @@ runs:
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' }}
Expand All @@ -47,23 +45,12 @@ runs:
# 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
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
91 changes: 91 additions & 0 deletions .github/workflows/binary-release-single.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Binary Release (single)

on:
workflow_dispatch:
inputs:
mlton-version:
required: true
type: string
runner:
required: true
type: string
binary-release-suffix:
required: false
type: string
workflow_call:
inputs:
mlton-version:
required: true
type: string
runner:
required: true
type: string
binary-release-suffix:
required: false
type: string

jobs:
binary-release-single:

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

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

env:
MLTON_VERSION: ${{ inputs.mlton-version }}
MLTON_BINARY_RELEASE_SUFFIX: ${{ inputs.binary-release-suffix }}

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
packboy: >-
github-cli:p
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: .github
ref: workflow-updates

- 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 -L https://github.com/${{ github.repository }}/releases/download/on-${MLTON_VERSION}-release/mlton-${MLTON_VERSION}.src.tgz | tar xz --strip-components=1
- name: Make binary release
if: ${{ false }}
run: |
# make binary-release \
PATH=$(pwd)/boot/bin:$PATH \
make \
OLD_MLTON_RUNTIME_ARGS="ram-slop 0.90" \
OLD_MLTON_COMPILE_ARGS="" \
MLTON_RUNTIME_ARGS="ram-slop 0.90" \
MLTON_COMPILE_ARGS="" \
$( if [[ -n "$WITH_GMP_DIR" ]]; then echo "WITH_GMP_DIR=$WITH_GMP_DIR"; fi ) \
MLTON_BINARY_RELEASE_SUFFIX=$MLTON_BINARY_RELEASE_SUFFIX \
binary-release
- name: Upload binary release
run: gh release upload on-${MLTON_VERSION}-release mlton-${MLTON_VERSION}*.tgz --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/binary-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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"
binary-release-suffix: ""
- runner: "macos-13"
binary-release-suffix: ""
- runner: "macos-14"
binary-release-suffix: ""
- runner: "windows-2022"
binary-release-suffix: ""

uses: ./.github/workflows/binary-release-single.yml
with:
mlton-version: ${{ inputs.mlton-version }}
runner: ${{ matrix.runner }}
binary-release-suffix: ${{ matrix.binary-release-suffix }}
secrets: inherit
19 changes: 12 additions & 7 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') }}
- name: Configure git
run: git config --global core.autocrlf false
shell: bash

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

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
33 changes: 33 additions & 0 deletions .github/workflows/source-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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
env:
MLTON_VERSION: ${{ inputs.mlton-version }}
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=${MLTON_VERSION} source-release
- name: Upload source release
run: gh release upload on-${MLTON_VERSION}-release mlton-${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 c777631

Please sign in to comment.