-
Notifications
You must be signed in to change notification settings - Fork 29
136 lines (120 loc) · 4.44 KB
/
deploy.yml
File metadata and controls
136 lines (120 loc) · 4.44 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
# Build, test, and deploy zentity for each supported version of Elasticsearch whenever pushing a release tag.
name: Deploy
on:
push:
tags:
- "zentity-*.*.*"
- "zentity-*.*.*-*"
jobs:
create_release:
name: Create Release
# Use the latest LTS OS.
runs-on: ubuntu-20.04
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_tag: ${{ steps.get_tag.outputs.tag }}
zentity_version: ${{ steps.get_zentity_version.outputs.first_match }}
steps:
# Checkout the repository.
# Uses: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v2
# Get the release tag.
- name: Get release tag
id: get_tag
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
# Get the zentity version by excluding the zentity- prefix in the release tag.
# Uses: https://github.com/AsasInnab/regex-action
- name: Get zentity version
id: get_zentity_version
uses: AsasInnab/regex-action@v1
with:
regex_pattern: "(?<=^zentity-).*"
regex_flags: "i"
search_string: "${{ steps.get_tag.outputs.tag }}"
# Create the release.
# Uses: https://github.com/actions/create-release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') || contains(github.ref, 'experimental') }}
body: "Releasing zentity-${{ steps.get_zentity_version.outputs.first_match }}"
build_and_upload_artifacts:
name: Build and Upload Artifacts
needs: create_release
# Use the latest LTS OS.
runs-on: ubuntu-20.04
# Set the zentity version as the value of the release tag.
env:
ZENTITY_VERSION: ${{ needs.create_release.outputs.zentity_version }}
strategy:
# Build and test zentity for each version of Elasticsearch that its APIs support.
matrix:
elasticsearch:
- 8.17.0
- 8.16.2
- 8.16.1
- 8.16.0
- 8.15.5
- 8.15.4
- 8.15.3
- 8.15.2
- 8.15.1
- 8.15.0
- 8.14.3
- 8.14.2
- 8.14.1
- 8.14.0
- 8.13.3
- 8.13.2
- 8.13.1
- 8.13.0
steps:
# Checkout the repository.
# Uses: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v2
# Configure the JDK.
# Uses: https://github.com/actions/setup-java
# Elasticsearch JVM support matrix: https://www.elastic.co/support/matrix#matrix_jvm
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
# Cache Maven packages.
# Uses: https://github.com/actions/cache
- name: Cache packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# Build and test zentity for a given version of Elasticsearch.
- name: Build and test
env:
ELASTICSEARCH_VERSION: ${{ matrix.elasticsearch }}
run: mvn --batch-mode clean install -Dzentity.version=$ZENTITY_VERSION -Delasticsearch.version=$ELASTICSEARCH_VERSION --file pom.xml
# Set the artifact name using the given versions of zentity and Elasticsearch.
- name: Set artifact name
id: set_artifact_name
env:
ELASTICSEARCH_VERSION: ${{ matrix.elasticsearch }}
run: echo ::set-output name=name::zentity-$ZENTITY_VERSION-elasticsearch-$ELASTICSEARCH_VERSION.zip
# Upload the release asset to: https://github.com/zentity-io/zentity/releases
# Uses: https://github.com/actions/upload-release-asset
- name: Upload release asset
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./target/releases/${{ steps.set_artifact_name.outputs.name }}
asset_name: ${{ steps.set_artifact_name.outputs.name }}
asset_content_type: application/zip