-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CI action #30
base: main
Are you sure you want to change the base?
Add CI action #30
Conversation
Hi @foxdalas, Thanks for the work done. I have a few questions:
|
Yes, you are right
No, a release is only created for new tags. (see push section)
I can add a tag pattern and specify the branch, as you wish. |
I think that releases should be issued only on the "main" branch with a tag. If I'm not mistaken, the condition will be as follows: if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main' As far as I understand, this condition should also be added to the "Checkout" and "Run the Maven verify phase" jobs. Ideally, it would be good to also release a Docker image. I looked at one of the forks, where the Docker image release is implemented https://github.com/brbcza/nexus-sso/blob/main/.github/workflows/deploy_release.yml, I think we can use this build script as a base to get something like this: steps:
- name: Checkout
uses: actions/checkout@v4
# Enable multi-architecture support on build node
- name: Set up QEMU
if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker buildx
if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Set up JDK 11 for x64
if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main'
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
architecture: x64
cache: 'maven'
- name: Run the Maven verify phase
if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main'
run: mvn --batch-mode --update-snapshots verify
- name: Login to GitHub container registry
if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image with Maven
if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main'
run: |
mvn install -PprepareImage
- name: Build and push Docker image
if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: .
push: true
build-args: |
NEXUS_VERSION=$GITHUB_REF_NAME
tags: |
ghcr.io/${{ github.repository }}:$GITHUB_REF_NAME
platforms: linux/amd64,linux/arm64,linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/') && github.ref == 'refs/heads/main'
with:
files: |
LICENSE
nexus-pac4j-plugin/target/*.jar
nexus-repository-services/target/*.jar
Of course I haven't tested this and most likely made a lot of mistakes. |
Hi @a-langer,
I've added a GitHub Action to your project. You can see an example release here.
Why this change? It allows everyone to easily obtain JAR files from your project and use them in their own projects and Docker files.