Publish release from master #3
This file contains hidden or 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: Publish Release | |
| run-name: "Publish release from ${{ github.ref_name }}" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| distinct_id: | |
| type: string | |
| required: false | |
| permissions: | |
| # Needed to push the tag. | |
| contents: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Echo distinct ID ${{ inputs.distinct_id }} | |
| run: echo ${{ inputs.distinct_id }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| # Include all tags in case the new tag already exists. | |
| fetch-tags: true | |
| - name: Set up Java 25 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: "25" | |
| distribution: "microsoft" | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v6 | |
| - name: Build | |
| run: ./gradlew build --stacktrace --warning-mode=fail | |
| - name: Create and push tag | |
| if: ${{ github.ref_type != 'tag' }} | |
| run: | | |
| VERSION=v$(grep "^version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r') | |
| git config --global user.name "Wurst-Bot" | |
| git config --global user.email "contact.wurstimperium@gmail.com" | |
| git tag "$VERSION" | |
| git push origin "$VERSION" | |
| - name: Publish to staging Maven repository | |
| run: ./gradlew publishAllPublicationsToStagingRepository --stacktrace | |
| - name: Set up SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| chmod 700 ~/.ssh | |
| printf '%s\n' "${{ secrets.MAVEN_DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519 | |
| chmod 600 ~/.ssh/id_ed25519 | |
| printf '%s\n' "${{ secrets.MAVEN_DEPLOY_KNOWN_HOSTS }}" > ~/.ssh/known_hosts | |
| chmod 644 ~/.ssh/known_hosts | |
| - name: Upload to Maven server | |
| run: | | |
| rsync -rlvz \ | |
| build/maven-repo/ \ | |
| "${{ secrets.MAVEN_DEPLOY_USER }}@${{ secrets.MAVEN_DEPLOY_HOST }}:" |