Skip to content

Commit

Permalink
BRE-345 - Update Java workflows (#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrassia authored Sep 27, 2024
1 parent 2d1c687 commit 42b536a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/build-java.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
name: Build Java SDK

on:
push:
branches:
- main
- rc
- hotfix-rc
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -66,3 +65,24 @@ jobs:
- name: Build Maven
run: ./gradlew build
working-directory: languages/java

- name: Upload Java SDK Build
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: build
path: ${{ github.workspace }}/languages/java/build
if-no-files-found: error

- name: Upload Java SDK Build
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: resources
path: ${{ github.workspace }}/languages/java/src/main/resources
if-no-files-found: error

- name: Upload Java SDK Build
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: schemas
path: languages/java/src/main/java/bit/sdk/schema
if-no-files-found: error
36 changes: 33 additions & 3 deletions .github/workflows/publish-java.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Publish Java SDK
run-name: Publish Java SDK ${{ inputs.release_type }}

Expand All @@ -13,6 +14,11 @@ on:
- Release
- Dry Run

defaults:
run:
shell: bash
working-directory: languages/java

env:
_KEY_VAULT: "bitwarden-ci"

Expand All @@ -29,17 +35,17 @@ jobs:
- name: Branch check
if: ${{ inputs.release_type != 'Dry Run' }}
run: |
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
echo "==================================="
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches"
echo "[!] Can only release from the 'main' branch"
echo "==================================="
exit 1
fi
- name: Get version
id: version
run: |
VERSION=$(cat languages/java/build.gradle | grep -Eo 'version = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
VERSION=$(cat build.gradle | grep -Eo 'version = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
echo "version=$VERSION" >> $GITHUB_OUTPUT
publish:
Expand Down Expand Up @@ -72,6 +78,30 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0

- name: Download Java SDK Build
uses: bitwarden/gh-actions/download-artifacts@main
with:
workflow: build-java.yml
workflow_conclusion: success
artifacts: build
path: languages/java/build

- name: Download Java Resources
uses: bitwarden/gh-actions/download-artifacts@main
with:
workflow: build-java.yml
workflow_conclusion: success
artifacts: resources
path: languages/java/src/main/resources

- name: Download Java Resources
uses: bitwarden/gh-actions/download-artifacts@main
with:
workflow: build-java.yml
workflow_conclusion: success
artifacts: schemas
path: languages/java/src/main/java/bit/sdk/schema

- name: Publish package to GitHub Packages
if: ${{ inputs.release_type != 'Dry Run' }}
run: ./gradlew publish
Expand Down

0 comments on commit 42b536a

Please sign in to comment.