Skip to content

Commit

Permalink
Update maven-release.yml
Browse files Browse the repository at this point in the history
* Updated maven-release.yml
* Updated maven-release.yml permissions
* Updated maven-deploy.yml
* Updated maven-deploy.yml: perform section updated
* Skip reactor deployment
* Setup tmate SSH session
* Factorized steps in maven-deploy.yaml
* Fixed maven-release.yaml
* Added SSH session on maven-release.yml
* SSH session on maven-release.yml only in the last job
* Fixed GitHub Pages release workflow
* Fixed GitHub Pages release workflow
[maven-release-plugin] prepare release v1.0.00

* Testing
* Testing: Fixed pom.xml
* Testing 1
* Testing 2
* Testing 3
* Testing 4
* Testing 5
* Testing 6
* Testing 7
* Testing 8
* Testing 9
* Testing 10
* Testing 10
* Testing 11
* Testing 12
* Testing 12
* Testing 13
* Fix 13
* Test 14
* Test15
* Test 16
* Test 17
* Test 18
* Test 19
* Test 19
* Test 20
* Test 21
* Test 22
* Test 23
* Test 23 SSH
* Fix and SSH
* Fix and SSH 2
* Finalize 1
* Finalize 2
* Finalize 3
  • Loading branch information
NassimBtk committed Jan 10, 2024
1 parent 6a6a973 commit 4017468
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 80 deletions.
44 changes: 15 additions & 29 deletions .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@ on:
push:
branches: [ "main" ]

# Default to bash
defaults:
run:
shell: bash

jobs:
build-linux:
runs-on: ubuntu-latest
deploy:

permissions:
contents: write
packages: write

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -29,36 +39,12 @@ jobs:
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build and Deploy from ubuntu-latest
run: mvn -B deploy
- name: Build and Deploy from ${{ matrix.os }}
run: mvn -B deploy --file pom.xml -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}

# Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Maven Dependency Tree Dependency Submission
uses: advanced-security/[email protected]

build-windows:
runs-on: windows-latest

permissions:
contents: write
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build and Deploy from windows-latest
run: mvn -B deploy
env:
GITHUB_TOKEN: ${{ github.token }}

100 changes: 68 additions & 32 deletions .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ permissions:
pull-requests: write
pages: write
id-token: write
packages: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these releases and deployments to complete.
Expand Down Expand Up @@ -90,33 +91,47 @@ jobs:
git tag -d ${{ env.tagName }} || true
git push origin :refs/tags/${{ env.tagName }} || true
- name: Prepare release
id: prepare
- name: Update project version to ${{ inputs.releaseVersion }}
run: |
mvn -B -U \
release:clean \
release:prepare \
-DpreparationGoals="clean verify" \
-DreleaseVersion=${{ inputs.releaseVersion }} \
-DdevelopmentVersion=${{ inputs.developmentVersion }} \
-Dresume=false
env:
GITHUB_TOKEN: ${{ github.token }}
mvn versions:set -DnewVersion=${{ inputs.releaseVersion }}
mvn versions:commit
- name: Release rollback on failure
- name: Commit ${{ inputs.releaseVersion }}
run: |
mvn -B -U \
release:rollback \
if: always() && (steps.prepare.outcome == 'failure')
git add pom.xml metricshub-jre-linux/pom.xml metricshub-jre-windows/pom.xml
git commit -m "Updated POM version to ${{ inputs.releaseVersion }}"
- name: Create tag ${{ env.tagName }}
run: |
git tag -a ${{ env.tagName }} -m "Release ${{ env.tagName }}"
- name: Push tag ${{ env.tagName }}
run: |
git push origin ${{ env.tagName }}
- name: Prepare next version ${{ inputs.developmentVersion }}
run: |
mvn versions:set -DnewVersion=${{ inputs.developmentVersion }}
mvn versions:commit
git add pom.xml metricshub-jre-linux/pom.xml metricshub-jre-windows/pom.xml
git commit -m "Updated POM version to ${{ inputs.developmentVersion }}"
- name: Push next version ${{ inputs.developmentVersion }}"
run: |
git push origin ${{ env.branchName }}
release:
name: Release v${{ inputs.releaseVersion }}

runs-on: ${{ matrix.os }}
name: Release v${{ inputs.releaseVersion }} on ${{ matrix.config.os }}

needs: prepare

runs-on: ${{ matrix.config.os }}

strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
config:
- { os: ubuntu-latest, packageSuffix: linux }
- { os: windows-latest, packageSuffix: windows }

steps:

Expand All @@ -132,30 +147,48 @@ jobs:
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Checkout ${{ needs.prepare.outputs.tagName }} branch
run: |
git fetch
git checkout ${{ needs.prepare.outputs.tagName }} 2>/dev/null
- name: Perform release to GitHub Packages
id: perform
run: |
mvn -B -U \
release:perform \
-Dgoals=deploy \
-DworkingDirectory=$GITHUB_WORKSPACE/target/release \
-DreleaseVersion=${{ inputs.releaseVersion }} \
-DdevelopmentVersion=${{ inputs.developmentVersion }} \
clean deploy \
-s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Release rollback on failure
- name: Get Deployed Package Version ID from Versions
id: version-id
run: |
mvn -B -U \
release:rollback \
curl -X GET -H "Authorization: Bearer ${{env.GITHUB_TOKEN}}" https://api.github.com/orgs/sentrysoftware/packages/maven/org.sentrysoftware.metricshub-jre-${{ matrix.config.packageSuffix }}/versions >> $HOME/versionIds.json
echo "versionId=$(grep -B1 '"name": "${{ inputs.releaseVersion }}"' $HOME/versionIds.json | grep '"id":' | awk -F': ' '{print $2}' | tr -d ',')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ github.token }}
if: always() && (steps.perform.outcome == 'failure')

- name: Deployed Version ID
run: echo "The deployed Version ID is ${{ env.versionId }}"
if: always() && (steps.perform.outcome == 'failure')

- name: Package ${{ inputs.releaseVersion }} removal on failure
uses: actions/delete-package-versions@v4
with:
package-version-ids: ${{ env.versionId }}
package-name: org.sentrysoftware.metricshub-jre-${{ matrix.config.packageSuffix }}
package-type: maven
if: always() && (steps.perform.outcome == 'failure') && (env.versionId != '')

- uses: actions/upload-artifact@v4
with:
name: jre-${{ matrix.os }}
name: jre-${{ matrix.config.os }}
path: |
./target/release/target/*.buildinfo
./metricshub-jre-*/target/release/target/*.zip
./target/*.buildinfo
./metricshub-jre-*/target/*.zip
./metricshub-jre-*/target/*.buildinfo
# Finalize job
finalize:
Expand All @@ -164,6 +197,8 @@ jobs:
needs: [ prepare, release ]
steps:

- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
merge-multiple: true
Expand All @@ -175,8 +210,9 @@ jobs:
fail_on_unmatched_files: false
generate_release_notes: true
files: |
*.buildinfo
*.zip
./target/*.buildinfo
./metricshub-jre-*/target/*.zip
./metricshub-jre-*/target/*.buildinfo
- name: Create Pull Request from ${{ needs.prepare.outputs.branchName }} to ${{ github.event.repository.default_branch }}
uses: devops-infra/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions metricshub-jre-linux/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<build>
<plugins>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
Expand Down
4 changes: 2 additions & 2 deletions metricshub-jre-windows/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<build>
<plugins>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
Expand Down
21 changes: 6 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand All @@ -16,7 +14,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputTimestamp>2023-10-25T22:28:48Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2024-01-09T17:32:03Z</project.build.outputTimestamp>
</properties>

<organization>
Expand All @@ -40,7 +38,7 @@
<scm>
<connection>scm:git:https://github.com/sentrysoftware/metricshub-jre-builder.git</connection>
<url>https://maven.pkg.github.com/sentrysoftware/metricshub-jre-builder</url>
<tag>HEAD</tag>
<tag>v1.0.00</tag>
</scm>

<licenses>
Expand Down Expand Up @@ -98,6 +96,9 @@
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!-- artifact (Reproducible Build) -->
<plugin>
Expand Down Expand Up @@ -168,16 +169,6 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<!-- release -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down

0 comments on commit 4017468

Please sign in to comment.