-
Notifications
You must be signed in to change notification settings - Fork 6
136 lines (114 loc) Β· 4.91 KB
/
Copy pathpublish-release-artifacts.yaml
File metadata and controls
136 lines (114 loc) Β· 4.91 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
name: Publish SBOM/JARs for Release
on:
push:
tags:
- 'v*'
branches:
- 'rc-*'
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
publish-release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Validate Trigger Ref
run: |
REF_NAME="${{ github.ref_name }}"
echo "Running on ref: $REF_NAME"
if [[ "$REF_NAME" == "main" ]]; then
echo "β
Validated running on main branch."
elif [[ "$REF_NAME" =~ ^v ]]; then
echo "β
Validated running on release tag."
elif [[ "$REF_NAME" =~ ^rc- ]]; then
echo "β
Validated running on release candidate branch."
else
echo "::error::Trigger is only allowed on 'main' branch, 'rc-*' branches, or 'v*' release tags. Current ref: $REF_NAME"
exit 1
fi
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
java-version: '21'
distribution: 'zulu'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
cache: 'maven'
- name: Publish Maven Artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# The script expects GITHUB_TOKEN in settings.xml or environment
# We need to ensure settings.xml is configured correctly for GitHub Packages
# actions/setup-java does this if we set server-id
./tools/release/publish-mvn-artifacts.sh .
- name: Generate SBOMs and Build Bundles
if: startsWith(github.ref, 'refs/tags/v')
run: |
# This script builds the modules and generates SBOMs
./tools/release/generate-sbom.sh
- name: Build deployment JARs for release assets
if: startsWith(github.ref, 'refs/tags/v')
run: |
# generate-sbom.sh runs mvn clean verify, which removes shaded deployment JARs.
# Rebuild distribution artifacts for GitHub release upload.
# Each build.sh run cleans the full reactor, so stash JARs before the next build.
mkdir -p release-assets
./tools/build.sh -qd aws java/
cp java/impl/aws/target/deployment/psoxy-aws-*.jar release-assets/
./tools/build.sh -qd gcp java/
cp java/impl/gcp/target/deployment/psoxy-gcp-*.jar release-assets/
- name: Locate Artifacts
id: locate-artifacts
if: startsWith(github.ref, 'refs/tags/v')
run: |
AWS_JAR=$(find release-assets -name "psoxy-aws-*.jar" | head -n 1)
GCP_JAR=$(find release-assets -name "psoxy-gcp-*.jar" | head -n 1)
if [ -z "$AWS_JAR" ] || [ ! -f "$AWS_JAR" ]; then
echo "::error::AWS deployment JAR not found under release-assets"
exit 1
fi
if [ -z "$GCP_JAR" ] || [ ! -f "$GCP_JAR" ]; then
echo "::error::GCP deployment JAR not found under release-assets"
exit 1
fi
echo "aws_jar=$AWS_JAR" >> $GITHUB_OUTPUT
echo "gcp_jar=$GCP_JAR" >> $GITHUB_OUTPUT
# Rename SBOMs to likely match the release artifact naming convention if desired,
# or just keep as is. The generate-sbom.sh copies them to docs/aws/sbom.json
cp docs/aws/sbom.json psoxy-aws-sbom.json
cp docs/gcp/sbom.json psoxy-gcp-sbom.json
echo "aws_sbom=psoxy-aws-sbom.json" >> $GITHUB_OUTPUT
echo "gcp_sbom=psoxy-gcp-sbom.json" >> $GITHUB_OUTPUT
- name: Verify Release Exists
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=${{ github.ref_name }}
# Check if release exists; fail if not
if ! gh release view "$TAG_NAME" >/dev/null 2>&1; then
echo "::error::Release for tag $TAG_NAME not found. This workflow expects the release to be created separately."
exit 1
fi
echo "Release for $TAG_NAME verified."
- name: Upload Release Assets
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Use the tag that triggered this workflow as the release identifier
TAG_NAME=${{ github.ref_name }}
AWS_JAR="${{ steps.locate-artifacts.outputs.aws_jar }}"
GCP_JAR="${{ steps.locate-artifacts.outputs.gcp_jar }}"
AWS_SBOM="${{ steps.locate-artifacts.outputs.aws_sbom }}"
GCP_SBOM="${{ steps.locate-artifacts.outputs.gcp_sbom }}"
echo "Uploading assets to release $TAG_NAME..."
# Upload files with clobber to overwrite if they exist
gh release upload "$TAG_NAME" "$AWS_JAR" "$GCP_JAR" "$AWS_SBOM" "$GCP_SBOM" --clobber