Skip to content

Commit 27811f1

Browse files
Merge pull request #4 from asaasdev/feat/add-release-and-maven-plubish-workflows/API-1074
[API-1074] Adiciona worfklows para publicarem uma release automaticamente, e publicar a dependencia maven
2 parents 4d18e19 + e045666 commit 27811f1

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @asaasdev/ipa
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build and Release from Merged PR
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
jobs:
9+
create-release:
10+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Extract version from pom.xml
18+
id: extract_version
19+
run: |
20+
VERSION=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
21+
echo "VERSION=$VERSION"
22+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
23+
24+
- name: Create GitHub Release
25+
uses: softprops/action-gh-release@v2
26+
with:
27+
tag_name: v${{ steps.extract_version.outputs.VERSION }}
28+
name: Release v${{ steps.extract_version.outputs.VERSION }}
29+
generate_release_notes: false
30+
draft: false
31+
prerelease: false
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: publish_maven_central_repo.yml
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
permissions:
11+
contents: write
12+
id-token: write
13+
attestations: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- id: install-secret-key
20+
name: Install gpg secret key
21+
run: |
22+
cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
23+
24+
- name: Set up Maven Central Repository
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: '8'
28+
distribution: 'temurin'
29+
server-id: central
30+
server-username: MAVEN_USERNAME
31+
server-password: MAVEN_PASSWORD
32+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
33+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
34+
35+
- name: Extract Maven Artifacts
36+
id: maven_artifact
37+
run: |
38+
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
39+
echo "artifactId=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_OUTPUT
40+
41+
- name: Build Java Project
42+
run: mvn clean package -ntp
43+
44+
- name: Publish package
45+
run: |
46+
mvn \
47+
--no-transfer-progress \
48+
--batch-mode \
49+
-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
50+
clean deploy -P release-sign-artifacts -e
51+
env:
52+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
53+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
54+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
55+
56+
- name: Publish Java Artifacts to GitHub Release
57+
run: |
58+
cp pom.xml ${{ steps.maven_artifact.outputs.artifactId }}-${{ steps.maven_artifact.outputs.version }}.pom
59+
gh release upload ${{github.event.release.tag_name}} "${{ steps.maven_artifact.outputs.artifactId }}-${{ steps.maven_artifact.outputs.version }}.pom"
60+
for jar in target/*.jar; do
61+
[ -e "$jar" ] || continue
62+
gh release upload ${{github.event.release.tag_name}} "$jar"
63+
done
64+
env:
65+
GITHUB_TOKEN: ${{ github.TOKEN }}
66+
67+
- name: GitHub Attestation for JAR files
68+
uses: actions/attest-build-provenance@v2
69+
with:
70+
subject-path: "target/*.jar"
71+
72+
- name: GitHub Attestation for POM file
73+
uses: actions/attest-build-provenance@v2
74+
with:
75+
subject-path: "pom.xml"
76+
subject-name: "${{ steps.maven_artifact.outputs.artifactId }}-${{ steps.maven_artifact.outputs.version }}.pom"

0 commit comments

Comments
 (0)