Repository navigation
145 lines (120 loc) · 4.5 KB
/
Copy pathrelease.yaml
File metadata and controls
145 lines (120 loc) · 4.5 KB
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
136
137
138
139
140
141
142
143
144
145
# Create release files and publish Docker images
name: Release
on:
release:
types: [published]
env:
DOCKER_IMAGE: ohdsi/webapi
jobs:
# Build JAR and WAR and attach them to the GitHub Release
upload:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Check out the exact commit associated with the release tag
- name: Checkout release tag
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
# The miredot plugin's POM cannot be resolved by Maven 3.10+
# (${toolsjar} is never set), so pin Maven 3.9.16.
- name: Set up Maven
run: |
curl -fsSL https://archive.apache.org/dist/maven/maven-3/3.9.16/binaries/apache-maven-3.9.16-bin.tar.gz | tar xz -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/apache-maven-3.9.16/bin" >> "$GITHUB_PATH"
- name: Maven cache
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Build executable JAR
- name: Build JAR
run: mvn -B -DskipTests=true -DskipUnitTests=true -Dpackaging.type=jar package
# Build deployable WAR for Tomcat
- name: Build WAR
run: mvn -B -DskipTests=true -DskipUnitTests=true package
# Keep original filenames for direct deployment.
# Generate checksums for verifying downloaded artifacts.
- name: Prepare release assets
shell: bash
run: |
set -euo pipefail
mkdir -p dist
cp target/WebAPI.jar dist/WebAPI.jar
cp target/WebAPI.war dist/WebAPI.war
cd dist
sha256sum WebAPI.jar WebAPI.war > SHA256SUMS.txt
# Attach artifacts to the existing GitHub Release.
# This does not create a new release.
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name }}
files: |
dist/WebAPI.jar
dist/WebAPI.war
dist/SHA256SUMS.txt
fail_on_unmatched_files: true
overwrite_files: true
# Build and push tagged release Docker image to
# ohdsi/webapi:<version> and ohdsi/webapi:latest.
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Add Docker labels and tags
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
# Setup Docker build environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set build parameters
id: build_params
run: |
echo "sha8=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
# Allow running the image on the architectures supported by the base image.
platforms: linux/amd64,linux/arm64
push: true
build-args: |
GIT_BRANCH=${{ steps.docker_meta.outputs.version }}
GIT_COMMIT_ID_ABBREV=${{ steps.build_params.outputs.sha8 }}
tags: ${{ steps.docker_meta.outputs.tags }}
# Use runtime labels from docker_meta as well as fixed labels
labels: |
${{ steps.docker_meta.outputs.labels }}
maintainer=Joris Borgdorff <joris@thehyve.nl>, Lee Evans - www.ltscomputingllc.com
org.opencontainers.image.authors=Joris Borgdorff <joris@thehyve.nl>, Lee Evans - www.ltscomputingllc.com
org.opencontainers.image.vendor=OHDSI
org.opencontainers.image.licenses=Apache-2.0
- name: Inspect image
run: |
docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}