-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automatic release workflow (#134)
* Add automatic release workflow * Increment version * Update developer guide --------- Co-authored-by: kaklakariada <[email protected]>
- Loading branch information
1 parent
22a74f8
commit 2b03c68
Showing
6 changed files
with
127 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
base_dir="$( cd "$(dirname "$0")/../.." >/dev/null 2>&1 ; pwd -P )" | ||
readonly base_dir | ||
readonly build_dir="$base_dir/build" | ||
readonly release_artifacts_dir="$build_dir/release-artifacts" | ||
|
||
cd "$base_dir" | ||
echo "Reading project version from Gradle project at ${base_dir}..." | ||
project_version=$(./gradlew properties --console=plain --quiet | grep "^version:" | awk '{print $2}') | ||
readonly project_version | ||
echo "Read project version '$project_version' from Gradle project" | ||
|
||
mkdir -p "$release_artifacts_dir" | ||
cp -v "$build_dir/libs/portmapper-$project_version-all.jar" "$release_artifacts_dir/portmapper-$project_version.jar" | ||
cp -v "$build_dir/libs-checksums/portmapper-$project_version-all.jar.sha512" "$release_artifacts_dir/portmapper-$project_version.jar.sha512" | ||
|
||
release_artifacts=$(find "$release_artifacts_dir" -type f) | ||
readonly release_artifacts | ||
|
||
readonly title="Release $project_version" | ||
readonly tag="$project_version" | ||
echo "Creating release:" | ||
echo "Git tag : $tag" | ||
echo "Title : $title" | ||
echo "Artifacts: $release_artifacts" | ||
|
||
# shellcheck disable=SC2086 | ||
release_url=$(gh release create --latest --title "$title" --target main "$tag" $release_artifacts) | ||
readonly release_url | ||
echo "Release URL: $release_url" |
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,57 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
skip-deploy-maven-central: | ||
description: "Skip deployment to Maven Central" | ||
required: true | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: "bash" | ||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: false | ||
permissions: | ||
contents: write # Required for creating GitHub release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Fail if not running on main branch | ||
if: ${{ github.ref != 'refs/heads/main' }} | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
core.setFailed('Not running on main branch, github.ref is ${{ github.ref }}. Please start this workflow only on main') | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: "temurin" | ||
java-version: 11 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v4 | ||
|
||
- name: Build | ||
run: ./gradlew build --info --warning-mode all | ||
|
||
- name: Publish to Maven Central | ||
if: ${{ !inputs.skip-deploy-maven-central }} | ||
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --info --warning-mode all | ||
env: | ||
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }} | ||
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }} | ||
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }} | ||
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} | ||
|
||
- name: Create GitHub Release | ||
run: ./.github/workflows/github_release.sh | ||
env: | ||
GH_TOKEN: ${{ github.token }} |
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
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