-
Notifications
You must be signed in to change notification settings - Fork 61
130 lines (115 loc) · 4.67 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
129
130
name: CI
on: [ push ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '11', '17' ]
permissions:
checks: write
contents: write
env:
AWS_REGION: "eu-west-1"
CONTAINER_BUILDER: "buildx"
SINCE_VERSION: "0.14.2"
TESTCONTAINERS_RYUK_DISABLED: "true"
steps:
- uses: actions/checkout@v4
- name: Install since
if: ${{ (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/develop') && matrix.java == '11' }}
run: |
cd "$( mktemp -d )"
curl --fail -L -o since.tar.gz https://github.com/release-tools/since/releases/download/v${SINCE_VERSION}/since_${SINCE_VERSION}_linux_amd64.tar.gz
tar xvf since.tar.gz
cp since /usr/local/bin
- name: Write changelog
if: ${{ (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/develop') && matrix.java == '11' }}
run: |
mkdir -p build
since changelog extract -q > build/CHANGES.md
cat build/CHANGES.md
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'gradle'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up build environment
run: |
chmod +x ./scripts/*.sh
# Disable gradle daemon
mkdir -p ~/.gradle
echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties
- name: Determine effective branch
id: git-meta
run: |
EFFECTIVE_BRANCH_NAME="$( ./scripts/get-effective-branch.sh )"
echo "EFFECTIVE_BRANCH=${EFFECTIVE_BRANCH_NAME}" >> $GITHUB_OUTPUT
- name: Test
run: ./gradlew test --info --stacktrace
- name: Publish Unit Test Results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "**/test-results/**/*.xml"
comment_mode: off
check_name: Unit Tests (Java ${{ matrix.java }})
- name: Build distributions
run: ./gradlew dist --info --stacktrace
- name: Integration test
run: |
./scripts/docker-build.sh -p false dev
./scripts/integration-tests.sh dev
- name: Build and push Docker images
id: docker-build
if: ${{ (startsWith(github.ref, 'refs/tags/') || steps.git-meta.outputs.EFFECTIVE_BRANCH == 'develop') && matrix.java == '11' }}
run: |
case ${{ steps.git-meta.outputs.EFFECTIVE_BRANCH }} in
develop)
./scripts/docker-build.sh -p true beta
;;
main)
CURRENT_VERSION="$( git describe --tags --exact-match )"
if [[ "${CURRENT_VERSION:0:1}" == "v" ]]; then
CURRENT_VERSION="$( echo ${CURRENT_VERSION} | cut -c 2- )"
fi
./scripts/docker-build.sh -p true "${CURRENT_VERSION}"
./scripts/docker-build.sh -p true "latest"
;;
release/2.x)
CURRENT_VERSION="$( git describe --tags --exact-match )"
if [[ "${CURRENT_VERSION:0:1}" == "v" ]]; then
CURRENT_VERSION="$( echo ${CURRENT_VERSION} | cut -c 2- )"
fi
./scripts/docker-build.sh -p true "${CURRENT_VERSION}"
;;
esac
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Release Java assets
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.java == '11' }}
uses: actions/github-script@v6
with:
script: |
const script = require('./.github/github-release.js')
await script({github, context}, [
'main',
'./distro/awslambda/build/distributions/imposter-awslambda.zip',
'./mock/hbase/build/libs/imposter-plugin-mock-hbase.jar',
'./mock/sfdc/build/libs/imposter-plugin-mock-sfdc.jar',
'./mock/wiremock/build/libs/imposter-plugin-wiremock.jar',
'./store/dynamodb/build/libs/imposter-plugin-store-dynamodb.jar',
'./store/graphql/build/libs/imposter-plugin-store-graphql.jar',
'./store/redis/build/libs/imposter-plugin-store-redis.jar',
'./lib/fake-data/build/libs/imposter-plugin-fake-data.jar',
])
- name: Publish Maven artifacts
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.java == '11' }}
run: ./gradlew publish --info --stacktrace
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}