Skip to content

Commit

Permalink
Release scripts and updates to pom (#401)
Browse files Browse the repository at this point in the history
* fix java install

* try out a cron job

* jreleaser.yml action

* update release scripts

* error in tag name parameter

* changelog tweaks

* Fix issue with dependabot changes in changelog.

Co-authored-by: Andres Almiray <[email protected]>

* cleanup github-release script

* set contenttype in gctoolkit release pipeline to Maven

---------

Co-authored-by: Andres Almiray <[email protected]>
  • Loading branch information
dsgrieve and aalmiray authored Nov 20, 2024
1 parent b9cac58 commit f3cdec5
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 77 deletions.
8 changes: 6 additions & 2 deletions .devops/gctoolkit-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
trigger: none
pr: none

variables:
JAVA_HOME_11_X64: /usr/lib/jvm/msopenjdk-11

resources:
repositories:
- repository: 1esPipelines
Expand Down Expand Up @@ -46,6 +49,8 @@ extends:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
env:
JAVA_HOME_11_X64: $(JAVA_HOME_11_X64)
displayName: 'Set Java to v11'

# download signing keys from Azure Key Vault
Expand Down Expand Up @@ -181,8 +186,7 @@ extends:
clientid: '516af6d8-6ab4-4069-8f64-b18c64d16688'
intent: 'PackageDistribution'
# Test with contentype PyPI to avoid publishing to Maven Central
# contenttype: 'Maven'
contenttype: 'PyPI'
contenttype: 'Maven'
contentsource: 'Folder'
folderlocation: '$(Build.ArtifactStagingDirectory)/staging'
waitforreleasecompletion: true
Expand Down
71 changes: 0 additions & 71 deletions .devops/pre-merge-checks.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .devops/scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -euxo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PROJECT_HOME=$SCRIPT_DIR/../..

cd $PROJECT_HOME

GIT_AUTHOR_NAME='Git' \
GIT_AUTHOR_EMAIL='[email protected]' \
GIT_COMMITTER_NAME='Git' \
GIT_COMMITTER_EMAIL='[email protected]' \
./mvnw -B -DskipTests clean release:clean release:prepare -Prelease -DpushChanges=false
22 changes: 22 additions & 0 deletions .devops/scripts/github-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -euxo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PROJECT_HOME=$SCRIPT_DIR/../..

cd $PROJECT_HOME

previous_release_version=$( \
curl --location --silent \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/microsoft/gctoolkit/releases/latest | grep 'tag_name' \
)
previous_release_version=$( perl -pe 's/"tag_name":\s+"(.*?)",?/$1/' <<< $previous_release_version )

release_version=$( git tag --sort=-taggerdate --list | head -n 1 )

./mvnw -B -pl :gctoolkit -Pjreleaser jreleaser:release \
-Djreleaser.previous.tag.name=${previous_release_version} \
-Djreleaser.tag.name=${release_version}

39 changes: 39 additions & 0 deletions .devops/weekly-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

trigger: none

schedules:
- cron: 0 0 * * 0
displayName: "Weekly build"
branches:
include: [ main ]
always: true

variables:
JAVA_HOME_11_X64: /usr/lib/jvm/msopenjdk-11

pool:
name: JEG-mariner2.0-x64-release

steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
env:
JAVA_HOME_11_X64: $(JAVA_HOME_11_X64)
displayName: 'Set Java to v11'

- checkout: self
clean: true

- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean package'
options: '-B -Prelease'
mavenOptions: '-s $(Build.SourcesDirectory)/.devops/feed-settings.xml'
mavenAuthenticateFeed: true
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
displayName: 'Build with Maven'
53 changes: 53 additions & 0 deletions .github/workflows/jreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release to GitHub using JReleaser

on:
workflow_dispatch:

jobs:
publish:

runs-on: ubuntu-latest

steps:
- name: Checkout project
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: main
fetch-depth: 0

- name: Cache Maven
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Setup Java JDK
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with:
java-version: '11'
distribution: 'microsoft'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN

- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "GitHub"
git config committer.name "GitHub"
git config committer.email "[email protected]"
- name: Version
id: version
run: |
release_version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
release_version=${release_version%-*}
echo ::set-output name=version::${release_version}
- name: Git-release
run: |
./mvnw -B versions:set -DnewVersion=${{steps.version.outputs.version}}
./mvnw -B -pl :gctoolkit -Pjreleaser jreleaser:release
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 27 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<properties>
<revision>3.0.3-SNAPSHOT</revision>
<checkstyle.version>10.18.2</checkstyle.version>
<jreleaser.plugin.version>1.14.0</jreleaser.plugin.version>
<jreleaser.plugin.version>1.15.0</jreleaser.plugin.version>
<junit5.version>5.11.1</junit5.version>
<maven.antrun-plugin.version>3.1.0</maven.antrun-plugin.version>
<maven.changes-plugin.version>2.12.1</maven.changes-plugin.version>
Expand Down Expand Up @@ -541,25 +541,44 @@
<skipTag>true</skipTag>
<changelog>
<formatted>ALWAYS</formatted>
<preset>conventional-commits</preset>
<labelers>
<labeler>
<label>maven-release</label>
<title>[maven-release-plugin]</title>
</labeler>
<labeler>
<label>bots</label>
<contributor>dependabot[bot]</contributor>
</labeler>
<labeler>
<label>not-github-issue</label>
<title>regex:.*(?!#\\d+).*</title>
</labeler>
<labeler>
<label>github-issue</label>
<title>#</title>
</labeler>
</labelers>
<categories>
<category>
<title>bots</title>
<labels>bots</labels>
<order>1</order>
</category>
<category>
<title>maven-release</title>
<labels>maven-release</labels>
<order>2</order>
</category>
<category>
<title>not-github-issue</title>
<labels>not-github-issue</labels>
<order>4</order>
</category>
<category>
<title>♻️ Changes</title>
<labels>github-issue</labels>
<order>3</order>
</category>
</categories>
<contributors>
Expand All @@ -569,10 +588,14 @@
</contributors>
<hide>
<contributors>
GitHub
<contributor>GitHub</contributor>
<contributor>Git</contributor>
<contributor>dependabot[bot]</contributor>
</contributors>
<categories>
maven-release
<category>maven-release</category>
<category>bots</category>
<category>not-github-issue</category>
</categories>
</hide>
</changelog>
Expand Down

0 comments on commit f3cdec5

Please sign in to comment.