-
Notifications
You must be signed in to change notification settings - Fork 101
135 lines (131 loc) · 4.65 KB
/
release.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
#
name: Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
required: true
type: string
latestTag:
description: 'Tag the Docker image as the latest'
required: true
type: boolean
default: true
run-name: Release ${{ github.event.inputs.tag }}
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Docker Tags
id: docker-tags
run: |
if [[ ! ${{ github.event.inputs.tag }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
echo "Tag format is invalid. Please use vX.Y.Z or vX.Y.Z-<qualifier>."
exit 1
fi
selectedTag=${{ github.event.inputs.tag }}
version=${selectedTag#v}
if [[ ${{ github.event.inputs.latestTag }} == true ]]; then
tags=eclipsejifa/jifa:latest,eclipsejifa/jifa:${version}
else
tags=eclipsejifa/jifa:${version}
fi
echo "Docker Tags: $tags"
echo "::set-output name=tags::$tags"
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME}}
password: ${{ secrets.DOCKER_PASSWORD}}
- name: Build for amd64
uses: docker/build-push-action@v5
with:
context: .
file: ./build.Dockerfile
tags: jifa-build:latest
platforms: linux/amd64
load: true
build-args: |
GRADLE_ARGS="clean build -Declipse-mat-deps.os=linux -Declipse-mat-deps.arch=amd64"
push: false
- name: Copy build artifacts from image
run: |
rm -rf ./jifa-build
rm -rf ./jifa-artifacts
mkdir jifa-build
mkdir jifa-artifacts
docker create --name jifa-build jifa-build:latest
docker cp jifa-build:/workspace/server/build/dependency jifa-build/amd64
docker cp jifa-build:/workspace/server/build/distributions/jifa.zip jifa-artifacts/jifa-linux-amd64.zip
docker rm jifa-build
- name: Build for arm64
uses: docker/build-push-action@v5
with:
context: .
file: ./build.Dockerfile
tags: jifa-build:latest
platforms: linux/amd64
load: true
build-args: |
GRADLE_ARGS="clean build -x test -Declipse-mat-deps.os=linux -Declipse-mat-deps.arch=aarch64"
push: false
- name: Copy build artifacts from image
run: |
docker create --name jifa-build jifa-build:latest
docker cp jifa-build:/workspace/server/build/dependency jifa-build/arm64
docker cp jifa-build:/workspace/server/build/distributions/jifa.zip jifa-artifacts/jifa-linux-arm64.zip
docker rm jifa-build
- name: Build and push final image
uses: docker/build-push-action@v5
with:
context: .
file: ./final.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker-tags.outputs.tags }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag }}
release_name: Release ${{ github.event.inputs.tag }}
draft: false
prerelease: false
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./jifa-artifacts/jifa-linux-amd64.zip
asset_name: jifa-linux-amd64.zip
asset_content_type: application/zip
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./jifa-artifacts/jifa-linux-arm64.zip
asset_name: jifa-linux-arm64.zip
asset_content_type: application/zip