forked from wiremock/wiremock
-
Notifications
You must be signed in to change notification settings - Fork 33
134 lines (124 loc) · 5.63 KB
/
create-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
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Create Release
on:
push:
tags:
- "*-ui"
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
jdk: [ 11 ]
runs-on: ${{ matrix.os }}
env:
JDK_VERSION: ${{ matrix.jdk }}
outputs:
version: ${{ steps.vars.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set output
id: vars
run: |
echo "tag=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
echo "version=$(echo $GITHUB_REF | cut -d / -f 3 | sed 's/.\{3\}$//')" >> $GITHUB_OUTPUT
- name: Check output
run: |
echo ${{ steps.vars.outputs.tag }}
echo ${{ steps.vars.outputs.version }}
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build
run: ./gradlew jar shadowJar
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vars.outputs.tag }}
release_name: ${{ steps.vars.outputs.tag }}
body_path: RELEASE-NOTES.md
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/wiremock-standalone-${{ steps.vars.outputs.version }}.jar
asset_name: wiremock-standalone-${{ steps.vars.outputs.version }}.jar
asset_content_type: application/java-archive
docker:
runs-on: ubuntu-latest
needs: [ build ]
strategy:
matrix:
versions:
- IMAGES:
- holomekc/wiremock-gui:latest-alpine
- holomekc/wiremock-gui:${{ needs.build.outputs.version }}-alpine
CONTEXT: alpine
PLATFORMS: linux/amd64
- IMAGES:
- holomekc/wiremock-gui:latest
- holomekc/wiremock-gui:${{ needs.build.outputs.version }}
CONTEXT: .
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Checkout sources
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Wiremock Docker image
run: docker buildx build ${{ matrix.versions.CONTEXT }} --tag ${{ join(matrix.versions.IMAGES, ' --tag ') }} --build-arg WIREMOCK_VERSION=${{ needs.build.outputs.version }} --load
- name: Test Wiremock Docker image
run: |
# latest
docker container run -d --name test -p 8080:8080 ${{ matrix.versions.IMAGES[0] }}
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/mappings; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/matched; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/unmatched; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/state; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/files; do sleep 1; done'
docker container rm -f test
# version
docker container run -d --name test -p 8080:8080 ${{ matrix.versions.IMAGES[1] }}
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/mappings; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/matched; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/unmatched; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/state; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/files; do sleep 1; done'
docker container rm -f test
- name: Push wiremock-gui image to Docker HUB
run: docker buildx build ${{ matrix.versions.CONTEXT }} --tag ${{ join(matrix.versions.IMAGES, ' --tag ') }} --build-arg WIREMOCK_VERSION=${{ needs.build.outputs.version }} --platform ${{ matrix.versions.PLATFORMS }} --push