From 16ba1d6685d4030ac83fbd73f6b7ee8db4a04a28 Mon Sep 17 00:00:00 2001 From: Matthew Fluet Date: Sun, 22 Dec 2024 07:58:55 -0500 Subject: [PATCH] Experiment with a release workflow --- .github/workflows/binary-release.yml | 73 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 32 ++++++++++++ .github/workflows/source-release.yml | 33 +++++++++++++ Makefile | 2 +- 4 files changed, 139 insertions(+), 1 deletion(-) 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/workflows/binary-release.yml b/.github/workflows/binary-release.yml new file mode 100644 index 000000000..8c05ab7b5 --- /dev/null +++ b/.github/workflows/binary-release.yml @@ -0,0 +1,73 @@ +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: "" + + runs-on: ${{ matrix.runner }} + env: + MLTON_VERSION: ${{ inputs.mlton-version }} + MLTON_BINARY_RELEASE_SUFFIX: ${{ matrix.binary-release-suffix }} + + defaults: + run: + shell: ${{ (startsWith(matrix.runner, 'windows') && 'msys2 {0}') || 'bash' }} + + steps: + - 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: ${{ matrix.runner }} + install-llvm: false + + - name: Download and unpack source release + run: | + curl -O -L https://github.com/${{ github.repository }}/releases/download/on-${MLTON_VERSION}-release/mlton-${MLTON_VERSION}.src.tgz + tar xzf mlton-${MLTON_VERSION}.src.tgz + rm mlton-${MLTON_VERSION}.src.tgz + mv mlton-${MLTON_VERSION}/* . + rmdir mlton-${MLTON_VERSION} + + - name: Make binary release + run: | + 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="" \ + 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/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" \ *