Skip to content

Commit

Permalink
ci(snapshots): set Central snapshots repository for libcryostat depen…
Browse files Browse the repository at this point in the history
…dency only when publishing a snapshot (#479)

* ci(snapshots): set Central snapshots repository for libcryostat dependency only when publishing a snapshot

* apply snapshots profile in other mvn invocations

* Remove trailing slash in snapshotUrl

* Remove other trailing slash

* Leave trailing slash in repository tag

---------

Co-authored-by: Elliott Baron <[email protected]>
  • Loading branch information
andrewazores and ebaron authored Sep 11, 2024
1 parent ae25420 commit d95c369
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4
- id: get-version
run: |
PROJECT_VERSION="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
PROJECT_VERSION="$(mvn -Psnapshots help:evaluate -Dexpression=project.version -q -DforceStdout)"
echo "project-version=${PROJECT_VERSION}" >> "${GITHUB_OUTPUT}"
publish-snapshot:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ jobs:
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ hashFiles('**/pom.xml') }}
- run: mvn -B -U clean install
- run: mvn -B -U -Psnapshots clean install
- id: get-agent-version
run: |
echo "agent-version=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)" >> $GITHUB_OUTPUT
echo "agent-version=$(mvn -Psnapshots -q -DforceStdout help:evaluate -Dexpression=project.version)" >> $GITHUB_OUTPUT
- name: Get date tag
run: echo "DATE_TAG=$(date -uI)" >> "$GITHUB_ENV"
- name: Build container images and manifest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-central-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
distribution: 'temurin'
cache: maven
- name: Run a build of the code base before release
run: ./mvnw --batch-mode --no-transfer-progress clean install
run: ./mvnw --batch-mode --no-transfer-progress -Psnapshots clean install
# - name: Set release version
# run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.version }}
- name: Release with JReleaser
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Maven
run: ./mvnw -B -U package -s $GITHUB_WORKSPACE/settings.xml --file pom.xml
run: ./mvnw -Psnapshots -B -U package -s $GITHUB_WORKSPACE/settings.xml --file pom.xml

- name: Publish to GitHub Packages Apache Maven
run: ./mvnw deploy -s $GITHUB_WORKSPACE/settings.xml
run: ./mvnw -Psnapshots deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- uses: skjolber/maven-cache-github-action@v1
with:
step: restore
- run: mvn -B -U clean verify
- run: mvn -Psnapshots -B -U clean verify
- uses: skjolber/maven-cache-github-action@v1
with:
step: save
36 changes: 18 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@
<url>https://github.com/cryostatio/cryostat-agent/tree/main</url>
</scm>

<repositories>
<repository>
<id>s01.oss.sonatype.org-snapshot</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>

<properties>
<mainClass>io.cryostat.agent.Agent</mainClass>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -585,13 +571,10 @@
<maven-central>
<active>ALWAYS</active>
<url>https://s01.oss.sonatype.org/service/local</url>
<snapshotUrl>https://s01.oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
<snapshotUrl>https://s01.oss.sonatype.org/content/repositories/snapshots</snapshotUrl>
<closeRepository>true</closeRepository>
<releaseRepository>true</releaseRepository>
<stagingRepositories>target/staging-deploy</stagingRepositories>
<!-- TODO this is needed so that the <repositories> block at the top is accepted,
which we need because of our dependency on -SNAPSHOT versions of libcryostat -->
<verifyPom>false</verifyPom>
</maven-central>
</nexus2>
</maven>
Expand All @@ -603,6 +586,23 @@
</build>
</profile>

<profile>
<id>snapshots</id>
<repositories>
<repository>
<id>s01.oss.sonatype.org-snapshot</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>

<profile>
<id>publication</id>
<properties>
Expand Down
4 changes: 2 additions & 2 deletions release-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ set -euo pipefail
IFS=$'\n\t'

echo "📦 Staging artifacts..."
./mvnw --batch-mode --no-transfer-progress -Ppublication -DskipTests=true -Dskip.spotless=true
./mvnw --batch-mode --no-transfer-progress -Ppublication,snapshots -DskipTests=true -Dskip.spotless=true

echo "🚀 Releasing..."
./mvnw --batch-mode --no-transfer-progress -Prelease jreleaser:deploy
./mvnw --batch-mode --no-transfer-progress -Prelease,snapshots jreleaser:deploy

echo "🎉 Done!"

0 comments on commit d95c369

Please sign in to comment.