diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1e211cc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + + +jobs: + release: + name: Create release + runs-on: macos-latest + permissions: write-all + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Extract version name + id: extract_name + run: echo "name=$(echo ${GITHUB_REF##*/})" >>$GITHUB_OUTPUT + shell: bash + + - name: Checkout to push branch + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Generate changelog + id: changelog + uses: metcalfc/changelog-generator@v4.1.0 + with: + myToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Create release + id: create_release + uses: ncipollo/release-action@v1 + with: + name: Release ${{ steps.extract_name.outputs.name }} + body: ${{ steps.changelog.outputs.changelog }} + + publish: + name: Publish release + permissions: write-all + runs-on: macos-latest + needs: release + steps: + - name: Checkout to push branch + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Extract version from tag + uses: damienaicheh/extract-version-from-tag-action@v1.1.0 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'corretto' + + - name: Publish to MavenCentral + run: ./gradlew publishAllPublicationsToSonatypeRepository + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}