Skip to content

Commit

Permalink
Deploy GraalSqueak components as GitHub releases
Browse files Browse the repository at this point in the history
and adjust how submodules are pulled
  • Loading branch information
fniephaus committed Mar 25, 2020
1 parent 3968ddd commit 9fee05b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 25 deletions.
46 changes: 21 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches-ignore:
- 'experiements/**'
create:
tags:
- '*'
pull_request:
branches:
- master
Expand All @@ -13,7 +16,8 @@ jobs:
name: Code Style and Build Config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Clone GraalSqueak repository
uses: actions/checkout@v2
- name: Check style and perform full build
run: |
# Install pylint
Expand Down Expand Up @@ -44,10 +48,10 @@ jobs:
name: Test on Linux with Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: git submodule update --init --recursive
- name: Clone GraalSqueak repository
uses: actions/checkout@v2
with:
submodules: true
- name: Set up dependencies
shell: bash
run: |
Expand Down Expand Up @@ -89,19 +93,16 @@ jobs:
- name: Run tinyBenchmarks on Native Image
run: graalsqueak --native --code "1 tinyBenchmarks" images/test-64bit.image
- name: Upload GraalSqueak component
uses: actions/upload-artifact@v1
with:
name: ${{ env.INSTALLABLE_TARGET }}
path: ${{ env.INSTALLABLE_TARGET }}
run: mx.graalsqueak/utils.sh deploy-asset ${{ github.ref }} ${{ env.INSTALLABLE_TARGET }} ${{ secrets.GITHUB_TOKEN }}

macos:
name: Test on macOS with Graal
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: git submodule update --init --recursive
- name: Clone GraalSqueak repository
uses: actions/checkout@v2
with:
submodules: true
- name: Set up dependencies
shell: bash
run: |
Expand Down Expand Up @@ -135,19 +136,16 @@ jobs:
- name: Run tinyBenchmarks on Native Image
run: graalsqueak --native --code "1 tinyBenchmarks" images/test-64bit.image
- name: Upload GraalSqueak component
uses: actions/upload-artifact@v1
with:
name: ${{ env.INSTALLABLE_TARGET }}
path: ${{ env.INSTALLABLE_TARGET }}
run: mx.graalsqueak/utils.sh deploy-asset ${{ github.ref }} ${{ env.INSTALLABLE_TARGET }} ${{ secrets.GITHUB_TOKEN }}

windows:
name: Test on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: git submodule update --init --recursive
- name: Clone GraalSqueak repository
uses: actions/checkout@v2
with:
submodules: true
- name: Set up dependencies
shell: bash
run: |
Expand Down Expand Up @@ -175,7 +173,5 @@ jobs:
- name: Run tinyBenchmarks on GraalVM
run: graalsqueak.cmd --jvm --code "1 tinyBenchmarks" images/test-64bit.image
- name: Upload GraalSqueak component
uses: actions/upload-artifact@v1
with:
name: ${{ env.INSTALLABLE_TARGET }}
path: ${{ env.INSTALLABLE_TARGET }}
shell: bash
run: mx.graalsqueak/utils.sh deploy-asset ${{ github.ref }} ${{ env.INSTALLABLE_TARGET }} ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions mx.graalsqueak/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,55 @@ OS_NAME=$(uname -s | tr '[:upper:]' '[:lower:]')
JAVA_HOME_SUFFIX="" && [[ "${OS_NAME}" == "darwin" ]] && JAVA_HOME_SUFFIX="/Contents/Home"
readonly OS_NAME JAVA_HOME_SUFFIX


deploy-asset() {
if ! [[ "$1" =~ ^refs\/tags\/[[:digit:]] ]]; then
echo "Skipping deployment step (ref does not start with a digit)"
exit 0
fi
local git_ref=${1:10} # cut off 'refs/tags/'
local filename=$2
local auth="Authorization: token $3"
local release_id

tag_result=$(curl -L --retry 3 --retry-connrefused --retry-delay 2 -sH "${auth}" \
"https://api.github.com/repos/${GITHUB_SLUG}/releases/tags/${git_ref}")

if echo "${tag_result}" | grep -q '"id":'; then
release_id=$(echo "${tag_result}" | grep '"id":' | head -n 1 | sed 's/[^0-9]*//g')
echo "Found GitHub release #${release_id} for ${git_ref}"
else
# Retry (in case release was just created by some other worker)
tag_result=$(curl -L --retry 3 --retry-connrefused --retry-delay 2 -sH "${auth}" \
"https://api.github.com/repos/${GITHUB_SLUG}/releases/tags/${git_ref}")

if echo "${tag_result}" | grep -q '"id":'; then
release_id=$(echo "${tag_result}" | grep '"id":' | head -n 1 | sed 's/[^0-9]*//g')
echo "Found GitHub release #${release_id} for ${git_ref}"
else
create_result=$(curl -sH "${auth}" \
--data "{\"tag_name\": \"${git_ref}\",
\"name\": \"${git_ref}\",
\"body\": \"\",
\"draft\": false,
\"prerelease\": false}" \
"https://api.github.com/repos/${GITHUB_SLUG}/releases")
if echo "${create_result}" | grep -q '"id":'; then
release_id=$(echo "${create_result}" | grep '"id":' | head -n 1 | sed 's/[^0-9]*//g')
echo "Created GitHub release #${release_id} for ${git_ref}"
else
echo "Failed to create GitHub release for ${git_ref}"
exit 1
fi
fi
fi

curl --fail -o /dev/null -w "%{http_code}" \
-H "${auth}" -H "Content-Type: application/zip" \
--data-binary @"${filename}" \
"https://uploads.github.com/repos/${GITHUB_SLUG}/releases/${release_id}/assets?name=${filename}"
}

download-asset() {
local filename=$1
local git_tag=$2
Expand Down

0 comments on commit 9fee05b

Please sign in to comment.