This repository has been archived by the owner on Jun 1, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (105 loc) · 3.92 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Build
on: [push, pull_request]
# variables:
# scalafmt_version: 'foo'
# graalvm_version: 'bar'
#
# ^^^ This format from Azure Dev Pipelines doesnt seem to be supported yet with
# globally defining variables at top level of file :sadface:.
#
# TODO: eliminate hardcoded values once global vars are supported.
jobs:
# We currently use docker hub automated builds for reproducibility -- but those
# are so very very slow, so do a GHA build as well (that we don't push
# anywhere), just so we see failures in the Dockerfile in CI without waiting
# forever for DockerHub status (which also doesn't report back via GH checks).
build-docker:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- run: docker build -t mrothy/scalafmt-native .
- run: docker images
# Build native binaries for specific platforms
build-native:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-10.14, ubuntu-18.04]
include:
- os: ubuntu-18.04
graalvm_platform: linux-amd64
graalvm_bin_path: bin
graalvm_extra_params: "--static"
- os: macOS-10.14
graalvm_platform: darwin-amd64
graalvm_bin_path: Contents/Home/bin
steps:
- name: Download GraalVM
env:
VERSION: "19.3.0"
JAVA_MAJOR: "java8"
PLATFORM: ${{ matrix.graalvm_platform }}
run: |
curl -fsL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${VERSION}/graalvm-ce-${JAVA_MAJOR}-${PLATFORM}-${VERSION}.tar.gz \
--output graalvm.tgz
tar xzf graalvm.tgz && rm -rf graalvm.tgz
sudo mv graalvm-ce-${JAVA_MAJOR}-${VERSION} /usr/local/graalvm
- name: Install GraalVM native-image plugin
env:
BIN_PATH: /usr/local/graalvm/${{ matrix.graalvm_bin_path }}
run: ${BIN_PATH}/gu install native-image
- name: Install Coursier
run: |
curl -s -Lo coursier https://git.io/coursier-cli && \
chmod +x ./coursier && \
sudo mv ./coursier /usr/local/bin/coursier
- name: Fetch scalafmt classes
env:
SCALAFMT_VERSION: "2.3.2"
run: |
coursier fetch org.scalameta:scalafmt-cli_2.12:${SCALAFMT_VERSION} -p > .classpath
- name: Build scalafmt with assembly into JAR
env:
BIN_PATH: /usr/local/graalvm/${{ matrix.graalvm_bin_path }}
GRAALVM_EXTRA_PARAMS: ${{ matrix.graalvm_extra_params }}
JAVA_OPTS: "-Xmx=2g"
run: |
export CLASSPATH=$(<.classpath) && \
${BIN_PATH}/native-image \
${GRAALVM_EXTRA_PARAMS} \
--no-fallback \
--report-unsupported-elements-at-runtime \
--initialize-at-build-time \
--allow-incomplete-classpath \
--class-path $CLASSPATH org.scalafmt.cli.Cli \
scalafmt-native
- name: Create archive
env:
ARTIFACT: scalafmt-native_${{ matrix.graalvm_platform }}.tgz
run: tar -cvzf ${ARTIFACT} ./scalafmt-native
- uses: actions/upload-artifact@v1
with:
path: scalafmt-native_${{ matrix.graalvm_platform }}.tgz
name: scalafmt-native_${{ matrix.graalvm_platform }}
# Collate artifacts, upload to GitHub Releases on semver tags
releaser:
needs: [build-native]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v1
with:
name: scalafmt-native_darwin-amd64
path: .
- uses: actions/download-artifact@v1
with:
name: scalafmt-native_linux-amd64
path: .
- run: ls -lh
# TODO: generate changelog? or just handle via https://github.com/mroth/bump
- name: Release to GitHub
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
with:
files: "scalafmt*.tgz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}