diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 0000000..e8700d5 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,36 @@ +name: Publish SNAPSHOT + +on: + push: + branches: + - main + +permissions: + contents: read + packages: write + +jobs: + publish: + runs-on: ubuntu-latest + env: + GITHUB_ACTOR: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Java 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "17" + cache: maven + server-id: github + server-username: GITHUB_ACTOR + server-password: GITHUB_TOKEN + + - name: Run tests + run: mvn -B verify + + - name: Publish SNAPSHOT to GitHub Packages + run: mvn -B deploy -DskipTests diff --git a/README.md b/README.md index 64095e9..71a2903 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ ![CI](https://github.com/sMouaad/DevOps-Project/actions/workflows/ci.yml/badge.svg) ![Docker](https://github.com/sMouaad/DevOps-Project/actions/workflows/docker.yml/badge.svg) - Small NumPy-inspired Java library for ndarray operations, developed as a DevOps team project. Repository: https://github.com/sMouaad/DevOps-Project @@ -85,10 +84,38 @@ Current CI setup: - JaCoCo coverage artifacts are uploaded from `target/site/jacoco/`. - SonarQube analysis is triggered in the same workflow using repository secrets (`SONAR_HOST_URL` and `SONAR_TOKEN`). - SonarQube is configured to wait for the quality gate result. +- **SNAPSHOT publishing**: On every push to `main`, if tests pass, a SNAPSHOT artifact is published to GitHub Packages. +- Publishing is blocked if line coverage drops below 70%. + +### Using the SNAPSHOT + +Published package coordinates: + +```xml + + org.sadisamir + ndarray-library + 0.1.0-SNAPSHOT + +``` + +Add the package registry to your `pom.xml`: + +```xml + + + github + https://maven.pkg.github.com/sMouaad/DevOps-Project + + +``` -Planned CI quality hardening: +Publishing workflow summary: -- Optional minimum coverage threshold gate once pipeline is stable. +- runs only on pushes to `main` +- runs `mvn verify` before deploy +- deploys with Maven `deploy` to GitHub Packages +- keeps the project version on `*-SNAPSHOT` for now ## Docker @@ -114,11 +141,11 @@ docker run --rm ndarray-demo Images are published to GitHub Container Registry (`ghcr.io/smouaad/devops-project`): -| Tag | Description | -|-----|-------------| -| `main` | Latest build from main branch | +| Tag | Description | +| ----------- | --------------------------------------- | +| `main` | Latest build from main branch | | `` | Semantic version (e.g., `1.0.0`, `1.0`) | -| `` | Specific commit SHA | +| `` | Specific commit SHA | ### CI/CD Pipeline diff --git a/pom.xml b/pom.xml index da8b5f4..614fe1e 100644 --- a/pom.xml +++ b/pom.xml @@ -112,6 +112,27 @@ report + + check + verify + + check + + + + + BUNDLE + + + LINE + COVEREDRATIO + 0.70 + + + + + + @@ -129,6 +150,19 @@ + + + github + GitHub Packages + https://maven.pkg.github.com/${env.GITHUB_REPOSITORY} + + + github + GitHub Packages + https://maven.pkg.github.com/${env.GITHUB_REPOSITORY} + + +