|
| 1 | +name: Publish Release |
| 2 | +run-name: "Publish release from ${{ github.ref_name }}" |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + distinct_id: |
| 8 | + type: string |
| 9 | + required: false |
| 10 | + |
| 11 | +permissions: |
| 12 | + # Needed to push the tag. |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + publish: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + |
| 20 | + - name: Echo distinct ID ${{ inputs.distinct_id }} |
| 21 | + run: echo ${{ inputs.distinct_id }} |
| 22 | + |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v6 |
| 25 | + with: |
| 26 | + # Include all tags in case the new tag already exists. |
| 27 | + fetch-tags: true |
| 28 | + |
| 29 | + - name: Set up Java 25 |
| 30 | + uses: actions/setup-java@v5 |
| 31 | + with: |
| 32 | + java-version: "25" |
| 33 | + distribution: "microsoft" |
| 34 | + |
| 35 | + - name: Grant execute permission for gradlew |
| 36 | + run: chmod +x gradlew |
| 37 | + |
| 38 | + - name: Setup Gradle |
| 39 | + uses: gradle/actions/setup-gradle@v6 |
| 40 | + |
| 41 | + - name: Build |
| 42 | + run: ./gradlew build --stacktrace --warning-mode=fail |
| 43 | + |
| 44 | + - name: Create and push tag |
| 45 | + if: ${{ github.ref_type != 'tag' }} |
| 46 | + run: | |
| 47 | + VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r') |
| 48 | + git config --global user.name "Wurst-Bot" |
| 49 | + git config --global user.email "contact.wurstimperium@gmail.com" |
| 50 | + git tag "$VERSION" |
| 51 | + git push origin "$VERSION" |
| 52 | +
|
| 53 | + - name: Publish to staging Maven repository |
| 54 | + run: ./gradlew publishAllPublicationsToStagingRepository --stacktrace |
| 55 | + |
| 56 | + - name: Set up SSH |
| 57 | + run: | |
| 58 | + mkdir -p ~/.ssh |
| 59 | + chmod 700 ~/.ssh |
| 60 | + printf '%s\n' "${{ secrets.MAVEN_DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519 |
| 61 | + chmod 600 ~/.ssh/id_ed25519 |
| 62 | + printf '%s\n' "${{ secrets.MAVEN_DEPLOY_KNOWN_HOSTS }}" > ~/.ssh/known_hosts |
| 63 | + chmod 644 ~/.ssh/known_hosts |
| 64 | +
|
| 65 | + - name: Upload to Maven server |
| 66 | + run: | |
| 67 | + rsync -rltvz \ |
| 68 | + build/maven-repo/ \ |
| 69 | + "${{ secrets.MAVEN_DEPLOY_USER }}@${{ secrets.MAVEN_DEPLOY_HOST }}:" |
0 commit comments