|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout repository |
| 13 | + uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Set up JDK 21 |
| 16 | + uses: actions/setup-java@v4 |
| 17 | + with: |
| 18 | + distribution: 'temurin' |
| 19 | + java-version: '21' |
| 20 | + cache: 'maven' |
| 21 | + server-id: github |
| 22 | + server-username: ${{ github.actor }} |
| 23 | + server-password: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + |
| 25 | + - name: Import GPG key |
| 26 | + env: |
| 27 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 28 | + run: | |
| 29 | + echo "$GPG_PRIVATE_KEY" | gpg --batch --import |
| 30 | + gpg --list-secret-keys --keyid-format LONG |
| 31 | +
|
| 32 | + - name: Build and deploy |
| 33 | + env: |
| 34 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 35 | + run: ./mvnw -q -P release deploy -Dgpg.passphrase="$GPG_PASSPHRASE" |
| 36 | + |
| 37 | + - name: Deploy to GitHub Packages |
| 38 | + env: |
| 39 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 40 | + run: | |
| 41 | + ./mvnw -q -P release deploy -Dgpg.passphrase="$GPG_PASSPHRASE" \ |
| 42 | + -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/tcheeric/nostr-java |
| 43 | +
|
| 44 | + - name: Collect JAR artifacts |
| 45 | + run: | |
| 46 | + mkdir -p release-jars |
| 47 | + find . -name "*.jar" -path "*/target/*.jar" -not -name "*sources*" -not -name "*javadoc*" -exec cp {} release-jars/ \; |
| 48 | + if ! ls release-jars/*.jar 1> /dev/null 2>&1; then |
| 49 | + echo "Error: No JAR files found to upload." |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Create GitHub release |
| 54 | + id: create_release |
| 55 | + uses: actions/create-release@v1 |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + with: |
| 59 | + tag_name: ${{ github.ref }} |
| 60 | + release_name: ${{ github.ref_name }} |
| 61 | + draft: false |
| 62 | + env: |
| 63 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + run: | |
| 65 | + gh release create "${{ github.ref_name }}" \ |
| 66 | + --title "${{ github.ref }}" \ |
| 67 | + --notes "" \ |
| 68 | + --verify-tag \ |
| 69 | + --latest |
| 70 | +
|
| 71 | + - name: Upload JAR artifacts |
| 72 | + env: |
| 73 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + run: | |
| 75 | + for file in release-jars/*.jar; do |
| 76 | + gh release upload "${{ github.ref_name }}" "$file" --clobber |
| 77 | + done |
0 commit comments