-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEVOPS-1751] Pipeline for publishing java sdk to gradle (#740)
## Type of change <!-- (mark with an `X`) --> ``` - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [x] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> - **.github/workflows/build-java.yml:** Run build on `rc` and `hotfix-rc` and on PR. Change Publish task to package. - **.github/workflows/publish-java.yml** Add Publish workflow - **.github/workflows/version-bump.yml** Add Java SDK to version bump workflow - **languages/java/build.gradle** Change name of the package to `sdk-secrets`. Add `https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/` as repository to publish. ## Before you submit - Please add **unit tests** where it makes sense to do so
- Loading branch information
1 parent
37dc5d3
commit f01c270
Showing
4 changed files
with
111 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Publish Java SDK | ||
run-name: Publish Java SDK ${{ inputs.release_type }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_type: | ||
description: "Release Options" | ||
required: true | ||
default: "Release" | ||
type: choice | ||
options: | ||
- Release | ||
- Dry Run | ||
|
||
env: | ||
_KEY_VAULT: "bitwarden-ci" | ||
|
||
jobs: | ||
validate: | ||
name: Setup | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
version: ${{ steps.version.outputs.version }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Branch check | ||
if: ${{ inputs.release_type != 'Dry Run' }} | ||
run: | | ||
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then | ||
echo "===================================" | ||
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" | ||
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]+') | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
publish: | ||
name: Publish | ||
runs-on: ubuntu-22.04 | ||
needs: validate | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Azure login | ||
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 | ||
with: | ||
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} | ||
|
||
- name: Retrieve secrets | ||
id: retrieve-secrets | ||
uses: bitwarden/gh-actions/get-keyvault-secrets@main | ||
with: | ||
keyvault: ${{ env._KEY_VAULT }} | ||
secrets: "maven-sonartype-ssrh-username, | ||
maven-sonartype-ossrh-password" | ||
|
||
- name: Setup java | ||
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Publish package to GitHub Packages | ||
if: ${{ inputs.release_type != 'Dry Run' }} | ||
run: ./gradlew publish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
MAVEN_USERNAME: ${{ steps.retrieve-secrets.outputs.maven-sonartype-ssrh-username }} | ||
MAVEN_PASSWORD: ${{ steps.retrieve-secrets.outputs.maven-sonartype-ossrh-password }} |
This file contains 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
This file contains 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