Release Java SDK version #34
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
name: Release Java SDK version | |
on: [workflow_dispatch] | |
jobs: | |
release-version: | |
runs-on: ubuntu-latest | |
steps: | |
- id: checkout | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.FATTUREINCLOUD_BOT_TOKEN }} | |
- id: init-git | |
name: Init GIT | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "fattureincloud-bot" | |
- id: setup-node | |
name: Setup Node.js | |
uses: actions/setup-node@v3 | |
- id: setup-jdk | |
name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '8' | |
distribution: 'adopt' | |
- id: cache-gradle | |
name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- id: setup-libraries | |
name: Install libraries | |
run: | | |
npm install -g yarn | |
yarn global add standard-version | |
sudo add-apt-repository ppa:rmescandon/yq -y | |
sudo apt update | |
sudo apt install yq -y | |
cd ./scripts/ | |
yarn | |
# We read the version from the sdk-version.yaml file and create the tag | |
# If it is needed to bump version, launch the related workflow | |
- id: read-java-sdk-version | |
name: Read Java SDK version | |
run: | | |
SDK_VERSION=$(yq e '.info.version' ./sdk-version.yaml) | |
echo "Releasing version: $SDK_VERSION" | |
echo "sdk_version=$SDK_VERSION" >> $GITHUB_ENV | |
# Here we use standard-version just to generate the changelog | |
- id: generate-changelog | |
name: Generate Changelog | |
run: | | |
standard-version --skip.bump --skip.tag | |
- id: git-push | |
name: Pushing to Git repo | |
if: ${{ !env.ACT }} | |
run: | | |
git push origin | |
- id: save-commit-sha | |
name: Save latest commit sha | |
run: | | |
COMMIT_SHA=$(git rev-parse HEAD) | |
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_ENV | |
- id: create-tag | |
name: Create tag | |
if: ${{ !env.ACT }} | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/v${{ env.sdk_version }}", | |
sha: "${{ env.commit_sha }}" | |
}) | |
- id: validate-wrapper | |
name: Validate Gradle wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- id: executable-wrapper | |
name: Gradle Wrapper is made executable | |
run: | | |
chmod +x ./gradlew | |
- id: gradle-publish | |
name: Publish package with Gradle | |
if: ${{ !env.ACT }} | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | |
GPG_KEY: ${{ secrets.GPG_KEY }} | |
run: | | |
./gradlew build | |
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository |