Skip to content

Commit 61663fe

Browse files
committed
(ci) switch to automatic token authentication
1 parent 4b4c469 commit 61663fe

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed
+11-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
22
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
3+
# also ref:
4+
# Publishing packages to GitHub Packages:
5+
# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-maven#publishing-packages-to-github-packages
6+
#
7+
# Upgrade to Automatic token authentication, no need for personal access token anymore
8+
# ref: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token
9+
#
310

4-
name: Maven Package and Publish to GitHub Packages
11+
name: Publish to GitHub Packages
512

613
run-name: 'Package Publish #${{github.run_number}}'
714

815
on:
916
release:
1017
types: [published]
11-
1218
workflow_dispatch:
1319

1420
jobs:
1521
build:
1622
runs-on: ubuntu-latest
1723

1824
permissions:
19-
contents: read
2025
packages: write
26+
contents: read
2127

2228
steps:
23-
- name: Checkout code
29+
- name: Checkout Code
2430
uses: actions/checkout@v4
2531

2632
- name: Set up JDK
@@ -29,14 +35,10 @@ jobs:
2935
java-version: '21'
3036
distribution: 'oracle'
3137
server-id: 'github-package'
32-
cache: 'maven'
33-
34-
- name: Build with Maven
35-
run: mvn --batch-mode package --file pom.xml
3638

3739
- name: Publish to GitHub Packages Apache Maven
3840
run: mvn --batch-mode deploy
3941
env:
4042
GITHUB_MAVEN_URL: https://maven.pkg.github.com/${{github.repository}}
41-
GITHUB_TOKEN: ${{secrets.PACKAGE_PUBLISH_TOKEN}}
43+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
4244

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
target/
44
dependency-reduced-pom.xml
55

6+
# File for local testing
7+
src/test/java/TestField.java
8+
9+
# File generated by Idea
10+
.idea
11+
612
# Log file
713
*.log
814

pom.xml

+1-8
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@
4646
</dependency>
4747
</dependencies>
4848

49-
<pluginRepositories>
50-
<pluginRepository>
51-
<id>maven-snapshots</id>
52-
<url>https://repository.apache.org/content/repositories/snapshots/</url>
53-
</pluginRepository>
54-
</pluginRepositories>
55-
5649
<build>
5750
<plugins>
5851
<plugin>
@@ -127,8 +120,8 @@
127120
<distributionManagement>
128121
<repository>
129122
<id>github-package</id>
130-
<name>Github Package</name>
131123
<url>${env.GITHUB_MAVEN_URL}</url>
124+
<!-- refer to .github/workflows/maven-publish-ghpkg.yml -->
132125
</repository>
133126
</distributionManagement>
134127
</project>

0 commit comments

Comments
 (0)