disbale commit-history (#1265) (#1266) #639
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish snapshots to maven | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- 0.* | |
- fix-snapshot-upload | |
# Concurrency control to prevent race conditions in commit mapping | |
concurrency: | |
group: maven-publish-spark-snapshots | |
cancel-in-progress: false | |
jobs: | |
build-and-publish-snapshots: | |
strategy: | |
fail-fast: false | |
if: github.repository == 'opensearch-project/opensearch-spark' | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
id: checkout | |
# Extract version from build.sbt file | |
- name: Extract version from build.sbt | |
id: extract_version | |
run: | | |
# Extract the version from build.sbt | |
VERSION=$(grep -E 'ThisBuild / version := "[^"]+"' build.sbt | sed 's/.*"\(.*\)".*/\1/') | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "Using version: ${VERSION}" | |
# Capture the commit ID for metadata purposes | |
- name: Set commit ID | |
id: set_commit | |
run: | | |
COMMIT_ID=$(git log -1 --format='%H') | |
echo "commit_id=${COMMIT_ID}" >> $GITHUB_OUTPUT | |
echo "Using commit ID: ${COMMIT_ID}" | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 11 | |
- name: Set up SBT | |
uses: sbt/setup-sbt@v1 | |
- name: Publish to Local Maven | |
run: | | |
# Use -no-colors for cleaner logs | |
sbt -no-colors clean standaloneCosmetic/publishM2 | |
sbt -no-colors clean sparkPPLCosmetic/publishM2 | |
sbt -no-colors clean sparkSqlApplicationCosmetic/publishM2 | |
# Verify the published artifacts have the correct version | |
echo "Checking published artifacts:" | |
find $HOME/.m2/repository/org/opensearch/ -name "*${{ steps.extract_version.outputs.version }}*" || echo "No artifacts found with the expected version" | |
- uses: actions/checkout@v3 | |
with: | |
repository: 'opensearch-project/opensearch-build' | |
path: 'build' | |
- name: Load secrets (for Sonatype) | |
uses: 1password/load-secrets-action@v3 | |
with: | |
# Export loaded secrets as environment variables | |
export-env: true | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
SONATYPE_USERNAME: op://opensearch-infra-secrets/maven-central-portal-credentials/username | |
SONATYPE_PASSWORD: op://opensearch-infra-secrets/maven-central-portal-credentials/password | |
- name: Generate SHA and MD5 checksums | |
run: | | |
for i in `find ${HOME}/.m2/repository/org/opensearch/ -name "*.pom" -type f`; do sha512sum "$i" | awk '{print $1}' >> "$i.sha512"; done | |
for i in `find ${HOME}/.m2/repository/org/opensearch/ -name "*.jar" -type f`; do sha512sum "$i" | awk '{print $1}' >> "$i.sha512"; done | |
for i in `find ${HOME}/.m2/repository/org/opensearch/ -name "*.pom" -type f`; do sha256sum "$i" | awk '{print $1}' >> "$i.sha256"; done | |
for i in `find ${HOME}/.m2/repository/org/opensearch/ -name "*.jar" -type f`; do sha256sum "$i" | awk '{print $1}' >> "$i.sha256"; done | |
- name: Install required tools | |
run: sudo apt-get update && sudo apt-get install -y xmlstarlet jq | |
- name: Publish snapshots and update metadata | |
run: | | |
# Source the utility functions | |
source .github/publish-utils.sh | |
# Call the main function with version and commit ID | |
publish_snapshots_and_update_metadata "${{ steps.extract_version.outputs.version }}" "${{ steps.set_commit.outputs.commit_id }}" |