Skip to content

Commit

Permalink
adding Java release pipeline, small regex changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GoMati-MU committed Apr 15, 2024
1 parent 30220a3 commit 63e5b85
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 9 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/java-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: CI-java
on:
# remove push
push:
pull_request:
workflow_call:
inputs:
Expand Down Expand Up @@ -94,11 +92,8 @@ jobs:
mkdir -p $JAVA_RELEASE_FOLDER
cp $JAVA_BUILD_FOLDER/${{ matrix.module }}*.jar LICENSE $JAVA_RELEASE_FOLDER/
# - name: Debug pwd and ls
# run: pwd && ls -R java-connectors

- name: Cache assembly
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: ./java-connectors/release/${{ matrix.module }}*.jar
key: assembly-java-${{ github.run_id }}
95 changes: 95 additions & 0 deletions .github/workflows/java-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Publish New Java Release
on:
push:
tags:
- "*"
workflow_dispatch:

jobs:
validate-tag:
runs-on: ubuntu-latest
outputs:
draft_release: ${{ steps.get_tag.outputs.draft_release }}
tag: ${{ steps.get_tag.outputs.tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get tag, release mode
shell: bash
id: get_tag
run: |
if [[ ${GITHUB_REF##*/} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]];
then
draft_release=false
elif [[ ${GITHUB_REF##*/} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?(\+[A-Za-z0-9.]+)?$ ]];
then
draft_release=true
else
echo "Exiting, github ref needs to be a tag with format x.y.z or x.y.z-(alpha|beta|rc)"
exit 1
fi
echo "draft_release=$draft_release" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
build:
needs:
- validate-tag
uses: ./.github/workflows/java-build.yml
with:
version: ${{ needs.validate-tag.outputs.tag }}
secrets: inherit

create-release:
runs-on: ubuntu-latest
needs:
- validate-tag
- build
strategy:
# Avoid parallel uploads
max-parallel: 1
# GitHub will NOT cancel all in-progress and queued jobs in the matrix if any job in the matrix fails, which could create inconsistencies.
# If any matrix job fails, the job will be marked as failure
fail-fast: false
matrix:
module: ${{fromJSON(needs.build.outputs.modules)}}
env:
DRAFT_RELEASE: '${{ needs.validate-tag.outputs.draft_release }}'
TAG: ${{ needs.validate-tag.outputs.tag }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'gradle'

- name: Uncache assembly
uses: actions/cache/restore@v4
with:
path: |
./java-connectors/release/${{ matrix.module }}*.jar
key: assembly-java-${{ github.run_id }}
fail-on-cache-miss: true

- name: Package Connector
shell: bash
run: |
JAVA_RELEASE_FOLDER=java-connectors/release
FOLDER=${{ matrix.module }}-${{ env.TAG }}
mkdir -p $FOLDER
cp $JAVA_RELEASE_FOLDER/${{ matrix.module }}*.jar LICENSE $FOLDER/
zip -r "$FOLDER.zip" $FOLDER/
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
file: ${{ matrix.module }}-${{ env.TAG }}.zip
asset_name: "${{ matrix.module }}-${{ env.TAG }}.zip"
release_name: 'Stream Reactor ${{ env.TAG }}'
prerelease: ${{ env.DRAFT_RELEASE }}
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
shell: bash
id: get_tag
run: |
if [[ ${GITHUB_REF##*/} =~ ^[0-9]\.[0-9]\.[0-9]$ ]];
if [[ ${GITHUB_REF##*/} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]];
then
draft_release=false
elif [[ ${GITHUB_REF##*/} =~ ^[0-9]\.[0-9]\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?(\+[A-Za-z0-9.]+)?$ ]];
elif [[ ${GITHUB_REF##*/} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?(\+[A-Za-z0-9.]+)?$ ]];
then
draft_release=true
else
echo "Exiting, github ref needs to be a tag with format x.y.z or x.y.z+(alpha|beta|rc)"
echo "Exiting, github ref needs to be a tag with format x.y.z or x.y.z-(alpha|beta|rc)"
exit 1
fi
echo "draft_release=$draft_release" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 63e5b85

Please sign in to comment.