-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (94 loc) · 4.29 KB
/
ci.yaml
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
117
118
119
120
121
122
123
124
125
126
127
128
name: GraalVM Native Image
# https://blogs.oracle.com/developers/post/building-cross-platform-native-images-with-graalvm
# https://github.com/aws-actions/configure-aws-credentials
# https://www.graalvm.org/latest/docs/
# native-image -jar tcpping.jar --no-fallback --static --libc=musl --gc=G1 -march=native -H:+BuildReport -H:Name=tcpping-linux
# native-image -jar tcpping.jar --no-fallback --static --gc=G1 -march=native -H:+BuildReport -H:Name=tcpping-linux
# native-image -jar tcpping.jar --no-fallback --static --gc=G1 -H:+BuildReport -H:Name=tcpping-linux
# native-image -jar tcpping.jar --no-fallback --static --gc=G1 -H:+BuildReport -H:Name=tcpping-linux
# https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/
# Get Snapcraft credentials
# snapcraft export-login cred.json
# put the contents of cred.json into the secret SNAPCRAFT_TOKEN
on:
workflow_dispatch:
push:
tags:
- "*"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ngmaibulat/tcping
IMAGE_TAG: 0.0.${{ github.run_number }}
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
SNAP: tcping_0.0.${{ github.run_number }}_amd64.snap
jobs:
Run:
runs-on: ubuntu-latest
steps:
- name: Check AWS CLI
run: |
which aws
aws --version
- uses: actions/checkout@v3
- name: GitHub Action for GraalVM
uses: graalvm/setup-graalvm@v1 # https://github.com/marketplace/actions/github-action-for-graalvm
with:
java-version: '20.0.1'
distribution: 'graalvm' # New 'distribution' option
- name: Run single command
run: ls -la
- name: Build via Gradle
run: ./gradlew build
- name: JPackage
run: |
echo "https://docs.oracle.com/en/java/javase/20/docs/specs/man/jpackage.html"
rm -fr install
mkdir install
cp build/libs/tcpping-all.jar install/tcpping.jar
jpackage --version
- name: Make Native Image
run: |
cd install
native-image -jar tcpping.jar --no-fallback -H:+BuildReport -H:Name=tcpping-linux
./tcpping-linux
- name: Set Snap Version
run: |
sed -i 's/BUILD/${{ github.run_number }}/g' snapcraft.yaml
cat snapcraft.yaml
- name: Install Snapcraft
uses: snapcore/action-build@v1
- name: Check Snapcraft
run: |
ls -la *.snap
- name: Use Snapcraft
run: |
snapcraft whoami
snapcraft upload --release=stable ${{ ENV.SNAP }}
- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'eu-central-1'
- name: Upload to S3
run: |
dt=$(date +%Y-%m-%d)
aws s3 sync install s3://ngm-dev-s3/tcpping-$dt/linux
aws s3 sync install-macos s3://ngm-dev-s3/tcpping-$dt/macos
- name: Create Docker Image
uses: docker/build-push-action@v4
with:
context: .
# dockerfile: Dockerfile.native # Specify custom Dockerfile
push: false
tags: ${{ ENV.REGISTRY }}/${{ ENV.IMAGE_NAME }}:${{ ENV.IMAGE_TAG }}
- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
run: |
IMG=${{ ENV.REGISTRY }}/${{ ENV.IMAGE_NAME }}
IMAGE=${{ ENV.REGISTRY }}/${{ ENV.IMAGE_NAME }}:${{ ENV.IMAGE_TAG }}
LATEST=${{ ENV.REGISTRY }}/${{ ENV.IMAGE_NAME }}:latest
docker tag $IMAGE $LATEST
docker push $IMG --all-tags --quiet