Prepend library version with lemmy version #21
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: | |
needs: | |
- read-lemmy-version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0.9.6 | |
with: | |
versionSpec: 5.x | |
- id: gitversion | |
name: Use GitVersion | |
uses: gittools/actions/gitversion/execute@v0.9.6 | |
with: | |
useConfigFile: true | |
configFilePath: ./gitversion.yml | |
- id: version | |
run: version=${{ needs.read-lemmy-version.outputs.lemmyVersion }}-${{ steps.gitversion.outputs.semVer }} >> $GITHUB_ENV | |
- name: Display SemVer | |
run: 'echo "SemVer: ${{ needs.read-lemmy-version.outputs.lemmyVersion }}-${{ steps.gitversion.outputs.semVer }}"' | |
build: | |
needs: | |
- version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: temurin | |
- name: Build with Gradle | |
env: | |
ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }} | |
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 | |
with: | |
arguments: build | |
- name: Rename AAR | |
run: mv ./build/libs/jlemmy-${{ needs.version.outputs.version }}.jar ./jlemmy.jar | |
- uses: actions/upload-artifact@master | |
with: | |
name: jlemmy-jar | |
path: ./jlemmy.jar | |
release: | |
permissions: | |
contents: write | |
needs: | |
- version | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- 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@master | |
with: | |
name: jlemmy-jar | |
path: ./ | |
- name: Upload Artifact to Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
uses: 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@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: temurin | |
- name: Build with Gradle | |
env: | |
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | |
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SECRET }} | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PGP_PASSPHRASE }} | |
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 | |
with: | |
arguments: |- | |
-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 | |
read-lemmy-version: | |
runs-on: ubuntu-latest | |
outputs: | |
lemmyVersion: ${{ steps.version.outputs.lemmyVersion }} | |
steps: | |
- uses: actions/checkout@v3 | |
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]} | |
lemmyVersion=${BASH_REMATCH[1]} >> $GITHUB_ENV | |
else | |
echo Zoinks Scoob! | |
exit 1; | |
fi |