-
Notifications
You must be signed in to change notification settings - Fork 4.1k
223 lines (217 loc) · 9.14 KB
/
publish-java-cdk-command.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# Usage: This workflow can be invoked manually or by a slash command.
#
# To invoke via GitHub UI, go to Actions tab, select the workflow, and click "Run workflow".
#
# To invoke via slash command, use the following syntax in a comment on a PR:
# /publish-java-cdk # Run with the defaults (dry-run=false, force=false)
# /publish-java-cdk dry-run=true # Run in dry-run mode (no-op)
# /publish-java-cdk force=true # Force-publish if needing to replace an already published version
name: Publish Java CDK
on:
# Temporarily run on commits to the 'java-cdk/publish-workflow' branch.
# TODO: Remove this 'push' trigger before merging to master.
push:
branches:
- java-cdk/publish-workflow
inputs:
repo:
description: "Repo to check out code from. Defaults to the main airbyte repo."
workflow_dispatch:
inputs:
repo:
description: "Repo to check out code from. Defaults to the main airbyte repo."
# TODO: If publishing from forks is needed, we'll need to revert type to `string` of `choice`.
type: choice
required: true
default: airbytehq/airbyte
options:
- airbytehq/airbyte
dry-run:
description: "Dry run (no-op)"
required: true
type: boolean
default: false
force:
description: "Force release (ignore existing)"
required: true
type: boolean
default: false
gitref:
description: "The git ref to check out from the specified repository."
required: true
comment-id:
description: "Optional comment-id of the slash command. Ignore if not applicable."
required: false
# uuid:
# description: "Custom UUID of workflow run. Used because GitHub dispatches endpoint does not return workflow run id."
# required: false
concurrency:
group: publish-airbyte-cdk
cancel-in-progress: false
env:
# Use the provided GITREF or default to the branch triggering the workflow.
REPO: ${{ github.event.inputs.repo }}
GITREF: ${{ github.event.inputs.gitref || github.ref }}
FORCE: "${{ github.event.inputs.force == null && true || github.event.inputs.force }}"
DRY_RUN: "${{ github.event.inputs.dry-run == null && true || github.event.inputs.dry-run }}"
CDK_VERSION_FILE_PATH: "./airbyte-cdk/java/airbyte-cdk/src/main/resources/version.properties"
# Uncomment and replace above when CDK 0.1.0 is released:
# CDK_VERSION_FILE_PATH: "./airbyte-cdk/java/airbyte-cdk/src/main/resources/version.properties"
jobs:
# We are using these runners because they are the same as the one for `publish-command.yml`
# One problem we had using `ubuntu-latest` for example is that the user is not root and some commands would fail in
# `manage.sh` (specifically `apt-get`)
start-publish-docker-image-runner-0:
name: Start Build EC2 Runner 0
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: airbytehq/airbyte
ref: master
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
publish-cdk:
needs: start-publish-docker-image-runner-0
runs-on: ubuntu-latest
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ env.REPO }}
ref: ${{ env.GITREF }}
- name: Read Target Java CDK version
id: read-target-java-cdk-version
run: |
cdk_version=$(cat $CDK_VERSION_FILE_PATH | tr -d '\n')
if [[ -z "$cdk_version" ]]; then
echo "Failed to retrieve CDK version from $CDK_VERSION_FILE_PATH"
exit 1
fi
echo "CDK_VERSION=${cdk_version}" >> $GITHUB_ENV
- name: Check for already-published version (${{ env.CDK_VERSION }}, FORCE=${{ env.FORCE }})
if: ${{ !(env.FORCE == 'true') }}
run: |
GROUP_ID="io.airbyte"
ARTIFACT_ID="airbyte-cdk"
VERSION=${CDK_VERSION}
REPO_URL="https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars"
GROUP_ID_URL=$(echo $GROUP_ID | tr '.' '/')
URL="${REPO_URL}/${GROUP_ID_URL}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.pom"
echo "Checking if URL exists: ${URL}"
if curl --output /dev/null --silent --head --fail "$URL"; then
echo "Version ${VERSION} of ${ARTIFACT_ID} has already been published. Aborting."
exit 1
else
echo "Version ${VERSION} of ${ARTIFACT_ID} has not been published. Proceeding..."
fi
- name: Build Java CDK
run: ./gradlew --no-daemon :airbyte-cdk:java:airbyte-cdk:build
- name: Publish Java Modules to LocalMaven (Dry-Run)
run: ./gradlew --no-daemon :airbyte-cdk:java:airbyte-cdk:publishToLocalMaven
- name: Publish Java Modules to CloudRepo
if: ${{ env.DRY_RUN == 'false' }}
run: ./gradlew --no-daemon :airbyte-cdk:java:airbyte-cdk:publish
env:
CLOUDREPO_USER: ${{ secrets.CLOUDREPO_USER }}
CLOUDREPO_PASSWORD: ${{ secrets.CLOUDREPO_PASSWORD }}
- name: "Post failure to Slack channel `#dev-connectors-extensibility`"
if: ${{ failure() }}
uses: slackapi/[email protected]
continue-on-error: true
with:
channel-id: C04J1M66D8B
payload: |
{
"text": "Error during `publish-cdk` while publishing Java CDK!",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Error while publishing Java CDK!"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "See details on <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|GitHub>\n"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN_AIRBYTE_TEAM }}
- name: "Post success to Slack channel `#dev-connectors-extensibility`"
if: ${{ failure() }}
uses: slackapi/[email protected]
continue-on-error: true
with:
channel-id: C04J1M66D8B
payload: |
{
"text": "New version of Java CDK was successfully published!",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Java CDK published successfully!"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "See details on <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|GitHub>\n"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN_AIRBYTE_TEAM }}
# In case of self-hosted EC2 errors, remove this block.
stop-publish-docker-image-runner-0:
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
name: Stop Build EC2 Runner
needs:
- start-publish-docker-image-runner-0 # required to get output from the start-runner job
- publish-cdk # required to wait when the main job is done
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Checkout Airbyte
uses: actions/checkout@v3
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Stop EC2 runner
uses: airbytehq/[email protected]
with:
mode: stop
github-token: ${{ env.PAT }}
label: ${{ needs.start-publish-docker-image-runner-0.outputs.label }}
ec2-instance-id: ${{ needs.start-publish-docker-image-runner-0.outputs.ec2-instance-id }}