-
Notifications
You must be signed in to change notification settings - Fork 1.1k
122 lines (102 loc) · 4.33 KB
/
Copy pathupload-jar.yml
File metadata and controls
122 lines (102 loc) · 4.33 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
# ====================================================================================
# Purpose:
# This workflow builds and uploads a Beam Provider JAR to Google Cloud Storage (GCS).
# It is designed to release Beam providers earlier than standard Beam releases.
# The workflow:
# 1. Clones Apache Beam and builds the expansion service.
# 2. Adds this build as a dependency to the Beam Starter project.
# 3. Builds the Beam Starter project.
# 4. Uploads the bundled JAR to a specified GCS bucket.
#
# How to Run:
# This workflow is triggered manually via GitHub Actions `workflow_dispatch`.
# Required Inputs:
# - bucket_path: The GCS bucket destination (e.g., gs://my-bucket/path).
# Optional Inputs:
# - jar_name: The artifactId of the JAR (defaults to 'beam-sdks-java-io-expansion-service').
# ====================================================================================
name: Build and Upload Beam Jar
on:
workflow_dispatch:
inputs:
jar_name:
description: 'Name of the jar file (artifactId)'
required: false
default: 'beam-sdks-java-io-expansion-service'
beam_version:
description: 'Beam version to build (leave empty to auto-detect from Beam codebase)'
required: false
default: ''
destination_path:
description: 'Full GCS destination path including filename (e.g., gs://my-bucket/path/custom-jar.jar)'
required: true
permissions:
contents: read
jobs:
build-and-upload:
runs-on: [self-hosted, release]
steps:
- name: Set up Java
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
java-version: '17'
distribution: 'temurin'
- name: Clone Apache Beam
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: apache/beam
path: beam
persist-credentials: false
- name: Clone Beam Starter
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: apache/beam-starter-java-provider
path: beam-starter-java-provider
persist-credentials: false
- name: Remove default github maven configuration
run: rm ~/.m2/settings.xml
- name: Build Beam Expansion Service
working-directory: beam
run: ./gradlew -Ppublishing :sdks:java:io:expansion-service:PublishToMavenLocal -x test
- name: Add dependency to pom.xml
env:
JAR_NAME: ${{ github.event.inputs.jar_name }}
BEAM_VERSION: ${{ github.event.inputs.beam_version }}
run: |
python3 -c "
import os
pom_path = 'beam-starter-java-provider/pom.xml'
jar_name = os.environ.get('JAR_NAME')
beam_version = os.environ.get('BEAM_VERSION')
if not beam_version:
with open('beam/gradle.properties', 'r') as f:
for line in f:
if line.strip().startswith('version='):
beam_version = line.strip().split('=')[1]
break
if not beam_version:
raise ValueError('Could not determine Beam version')
with open(pom_path, 'r') as f:
content = f.read()
dependency_template = ''' <dependency>
<groupId>org.apache.beam</groupId>
<artifactId>@JAR_NAME@</artifactId>
<version>@BEAM_VERSION@</version>
</dependency>'''
dependency = dependency_template.replace('@JAR_NAME@', jar_name).replace('@BEAM_VERSION@', beam_version)
if '</dependencies>' in content:
content = content.replace('</dependencies>', dependency + '\n </dependencies>')
else:
print('Warning: </dependencies> not found in pom.xml')
with open(pom_path, 'w') as f:
f.write(content)
"
- name: Build Beam Starter
working-directory: beam-starter-java-provider
run: mvn package
- name: Rename JAR and Upload
working-directory: beam-starter-java-provider/target
env:
DESTINATION_PATH: ${{ github.event.inputs.destination_path }}
run: |
gcloud storage cp xlang-transforms-bundled-1.0-SNAPSHOT.jar "$DESTINATION_PATH"