|
| 1 | +name: IABGPP-Java Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'The release version (e.g., 3.x.x)' |
| 8 | + required: true |
| 9 | + default: '' |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + # Checkout the repository with full history for tagging |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + # Set up Java (assuming Java 11, adjust if different) |
| 22 | + - name: Set up Java |
| 23 | + uses: actions/setup-java@v2 |
| 24 | + with: |
| 25 | + java-version: '11' |
| 26 | + distribution: 'adopt' |
| 27 | + |
| 28 | + # Import GPG secret key for signing |
| 29 | + - name: Import GPG key |
| 30 | + run: | |
| 31 | + echo "${{ secrets.GPG_SECRET_KEY }}" > secret_key.asc |
| 32 | + gpg --import --no-tty --batch secret_key.asc || { echo "GPG import failed"; cat secret_key.asc; exit 1; } |
| 33 | + gpg --list-secret-keys |
| 34 | +
|
| 35 | + # Generate settings.xml with Maven repository credentials |
| 36 | + - name: Create settings.xml |
| 37 | + run: | |
| 38 | + mkdir -p ~/.m2 |
| 39 | + cat > ~/.m2/settings.xml << EOF |
| 40 | + <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> |
| 41 | + <localRepository>~/.m2</localRepository> <interactiveMode>false</interactiveMode> <offline>false</offline><pluginGroups> <pluginGroup>org.sonatype.plugins</pluginGroup> </pluginGroups> <servers> <server> <id>sonatype-nexus-snapshots</id> <username>TiW/t45q</username> <password>${{ secrets.SONATYPE_PWD }}</password> </server> <server> <id>sonatype-nexus-staging</id> <username>TiW/t45q</username> <password>${{ secrets.SONATYPE_PWD_STAGING }}</password> </server> </servers> |
| 42 | + </settings> |
| 43 | + EOF |
| 44 | +
|
| 45 | + # Pull latest changes from master |
| 46 | + - name: Pull latest changes |
| 47 | + run: git pull origin master |
| 48 | + |
| 49 | + # Set the release version in pom.xml |
| 50 | + - name: Set release version |
| 51 | + run: mvn versions:set -DnewVersion=${{ github.event.inputs.version }} -DgenerateBackupPoms=false |
| 52 | + |
| 53 | + # Build and deploy the release |
| 54 | + - name: Deploy release |
| 55 | + run: | |
| 56 | + echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf |
| 57 | + echo "use-agent" >> ~/.gnupg/gpg.conf |
| 58 | + export GPG_TTY=$(tty || echo /dev/tty) |
| 59 | + mvn clean deploy --settings ~/.m2/settings.xml -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -Prelease -Dmaven.javadoc.skip=true |
| 60 | +
|
| 61 | + # Commit the release version and create a tag |
| 62 | + - name: Commit and tag release |
| 63 | + run: | |
| 64 | + git config user.email "[email protected]" |
| 65 | + git config user.name "Mayank Mishra" |
| 66 | + git add . |
| 67 | + git commit -m "${{ github.event.inputs.version }}" |
| 68 | + git tag "${{ github.event.inputs.version }}" |
| 69 | +
|
| 70 | + # Set the next snapshot version |
| 71 | + - name: Set next snapshot version |
| 72 | + run: mvn versions:set -DnextSnapshot=true -DgenerateBackupPoms=false |
| 73 | + |
| 74 | + # Commit the snapshot version |
| 75 | + - name: Commit snapshot version |
| 76 | + run: | |
| 77 | + git add . |
| 78 | + git commit -m "${{ github.event.inputs.version }}-SNAPSHOT" |
| 79 | +
|
| 80 | + # Push commits and tags to GitHub |
| 81 | + - name: Push changes |
| 82 | + run: | |
| 83 | + git status |
| 84 | + git push; git push --tags |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{secrets.PAT}} |
0 commit comments