Update workflow to avoid deprecation #26
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: Build | |
'on': | |
pull_request: | |
branches: | |
- main | |
- develop | |
push: | |
branches: | |
- main | |
- develop | |
- release/** | |
permissions: | |
contents: write | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- id: version | |
run: |- | |
regex='"version": "(.*)",' | |
contents="$(cat ./type-generator/lemmy-js-client/package.json | grep "version")" | |
if [[ $contents =~ $regex ]] | |
then | |
echo ${BASH_REMATCH[1]} | |
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT | |
else | |
echo Zoinks Scoob! | |
exit 1; | |
fi | |
build: | |
needs: | |
- version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: temurin | |
- name: Setup gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Rename AAR | |
run: mv ./build/libs/jlemmy-${{ needs.version.outputs.version }}.jar ./jlemmy.jar | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: jlemmy-jar | |
path: ./jlemmy.jar | |
release: | |
permissions: | |
contents: write | |
needs: | |
- version | |
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Create tag for release | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
tag: v${{ needs.version.outputs.version }} | |
- id: create_release | |
name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: v${{ needs.version.outputs.version }} | |
name: Release ${{ needs.version.outputs.version }} | |
draft: false | |
prerelease: ${{ github.ref != 'refs/heads/main' }} | |
publish-release: | |
needs: | |
- version | |
- release | |
- build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: jlemmy-jar | |
path: ./ | |
- name: Upload Artifact to Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ./jlemmy.jar | |
asset_name: jlemmy-v${{ needs.version.outputs.version }}.jar | |
asset_content_type: application/zip | |
publish-sonatype: | |
permissions: | |
contents: read | |
needs: | |
- version | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: temurin | |
- name: Setup gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Build with Gradle | |
run: |- | |
./gradlew -Pversion=${{ needs.version.outputs.version }} | |
-Ppom.url="https://github.com/${{ github.repository }}" | |
-Ppom.scm.connection="scm:git:git://github.com/${{ github.repository }}" | |
-Ppom.scm.developerConnection="scm:git:ssh://github.com/${{ github.repository }}" | |
-Ppom.scm.url="https://github.com/${{ github.repository }}" | |
publishToCentralPortal --no-daemon |