Deploy To OSSRH And Release With Tag #22
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
# https://github.com/line/lich/blob/master/.github/workflows/ossrh.yml | |
name: Deploy To OSSRH And Release With Tag | |
on: | |
workflow_dispatch: | |
inputs: | |
cond_release: | |
description: 'Type "release" to release artifacts to Maven Central.' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: deploy | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: gradle/wrapper-validation-action@v1 | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- name: Decode Token To File | |
uses: timheuer/[email protected] | |
with: | |
fileName: 'verification.properties' | |
fileDir: './line-sdk/src/main/resources/META-INF/com/linecorp/linesdk/linesdk/' | |
encodedString: ${{ secrets.SDK_CONSOLE_TOKEN }} | |
- name: Deploy artifacts | |
env: | |
ORG_GRADLE_PROJECT_repositoryUsername: ${{ secrets.OSSRH_USERNAME }} | |
ORG_GRADLE_PROJECT_repositoryPassword: ${{ secrets.OSSRH_PASSWORD }} | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} | |
run: ./gradlew publish --stacktrace | |
- name: Release to Maven Central | |
if: ${{ github.event.inputs.cond_release == 'release' }} | |
env: | |
ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.OSSRH_USERNAME }} | |
ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.OSSRH_PASSWORD }} | |
run: ./gradlew closeAndReleaseRepository --stacktrace | |
tag_and_release: | |
name: Create Tag And Release | |
runs-on: ubuntu-latest | |
needs: deploy | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: Retrieve Version | |
run: | | |
version_output=$(${{github.workspace}}/gradlew -q printVersionName) | |
# Use awk to extract the last line from the output | |
# 'END{print line}' prints the last stored line after processing all input lines | |
VERSION_NAME=$(echo "$version_output" | awk '/./{line=$0} END{print line}') | |
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_OUTPUT | |
id: sdk_version | |
- name: Get Version | |
run: | | |
echo "VERSION_NAME=${{steps.sdk_version.outputs.VERSION_NAME}}" | |
- name: Create Tag | |
id: create_tag | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
CUSTOM_TAG: "v${{steps.sdk_version.outputs.VERSION_NAME}}" | |
- name: Create Release | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{steps.sdk_version.outputs.VERSION_NAME}}" | |
release_name: "Release ${{steps.sdk_version.outputs.VERSION_NAME}}" | |
draft: false | |
prerelease: false |