From c7776318aab51503a84494b7cd04ad1ff0ed56c2 Mon Sep 17 00:00:00 2001 From: Matthew Fluet Date: Mon, 23 Dec 2024 16:25:40 -0500 Subject: [PATCH] Experiment with a release workflow --- .../install-bootstrap-dependencies/action.yml | 32 ++----- .github/workflows/binary-release-single.yml | 91 +++++++++++++++++++ .github/workflows/binary-release.yml | 35 +++++++ .github/workflows/ci.yml | 19 ++-- .github/workflows/release.yml | 32 +++++++ .github/workflows/source-release.yml | 33 +++++++ Makefile | 2 +- 7 files changed, 213 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/binary-release-single.yml create mode 100644 .github/workflows/binary-release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/source-release.yml diff --git a/.github/actions/install-bootstrap-dependencies/action.yml b/.github/actions/install-bootstrap-dependencies/action.yml index 6f6b3bee0..56a753e9f 100644 --- a/.github/actions/install-bootstrap-dependencies/action.yml +++ b/.github/actions/install-bootstrap-dependencies/action.yml @@ -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' }} @@ -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' }} @@ -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}' @@ -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 diff --git a/.github/workflows/binary-release-single.yml b/.github/workflows/binary-release-single.yml new file mode 100644 index 000000000..7123e7f9b --- /dev/null +++ b/.github/workflows/binary-release-single.yml @@ -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 }} diff --git a/.github/workflows/binary-release.yml b/.github/workflows/binary-release.yml new file mode 100644 index 000000000..170ad9a85 --- /dev/null +++ b/.github/workflows/binary-release.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c11dfb3a4..9a5d83733 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,8 +4,6 @@ name: CI on: push: pull_request: - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..7c9c99cb4 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/source-release.yml b/.github/workflows/source-release.yml new file mode 100644 index 000000000..8f15a4bf7 --- /dev/null +++ b/.github/workflows/source-release.yml @@ -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 }} diff --git a/Makefile b/Makefile index 7bc899d16..21c434829 100644 --- a/Makefile +++ b/Makefile @@ -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" \ *