forked from piertv21/ditto-wodt-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: configure ci for building and release
- Loading branch information
1 parent
07e6b53
commit 5c3c039
Showing
3 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Build & Deploy | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- '.gitignore' | ||
- '.mergify.yml' | ||
- 'CHANGELOG.md' | ||
- 'LICENSE' | ||
- 'README.md' | ||
- 'renovate.json' | ||
pull_request: | ||
|
||
jobs: | ||
validation: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
- name: Validate the Gradle Wrapper | ||
uses: gradle/wrapper-validation-action@v3.5.0 | ||
|
||
build: | ||
needs: | ||
- validation | ||
strategy: | ||
matrix: | ||
os: [ubuntu, macos, windows] | ||
java-version: [17, 21] | ||
runs-on: ${{ matrix.os }}-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ matrix.java-version }} | ||
distribution: adopt | ||
- name: Run quality assurance and test with coverage | ||
run: ./gradlew clean check | ||
- name: CodeCov | ||
if: ${{ contains('Linux', runner.os) }} | ||
uses: codecov/codecov-action@v4.6.0 | ||
with: | ||
directory: "build/reports/jacoco" | ||
|
||
release-and-delivery: | ||
permissions: | ||
packages: write | ||
concurrency: | ||
# Allow only one release at a time. | ||
group: release-and-delivery-${{ github.event.number || github.ref }} | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release-status: ${{ env.release_status }} | ||
# Release only where secrets are available. | ||
if: >- | ||
!github.event.repository.fork | ||
&& ( | ||
github.event_name != 'pull_request' | ||
|| github.event.pull_request.head.repo.full_name == github.repository | ||
) | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
- name: Find the version of Node from package.json | ||
id: node-version | ||
run: echo "version=$(jq -r .engines.node package.json)" >> $GITHUB_OUTPUT | ||
- name: Install Node | ||
uses: actions/setup-node@v4.1.0 | ||
with: | ||
node-version: ${{ steps.node-version.outputs.version }} | ||
- name: Release and container delivery | ||
uses: AndreaGiulianelli/release-and-delivery-action@1.0.11 | ||
with: | ||
should-release: true | ||
release-command: | | ||
npm install | ||
npx semantic-release | ||
should-build-and-deliver-container: true | ||
container-registry-name: 'ghcr.io' | ||
container-registry-username: ${{ github.actor }} | ||
container-registry-password: ${{ secrets.GITHUB_TOKEN }} | ||
github-token: ${{ secrets.DEPLOYMENT_TOKEN }} | ||
|
||
success: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- validation | ||
- build | ||
- release-and-delivery | ||
if: >- | ||
always() && ( | ||
contains(join(needs.*.result, ','), 'failure') | ||
|| !contains(join(needs.*.result, ','), 'cancelled') | ||
) | ||
steps: | ||
- name: Verify that there were no failures | ||
run: ${{ !contains(join(needs.*.result, ','), 'failure') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"devDependencies": { | ||
"semantic-release-preconfigured-conventional-commits": "1.1.112" | ||
}, | ||
"engines": { | ||
"node": "20.18" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Load this configuration that provide all the base for working with conventional commits | ||
const config = require('semantic-release-preconfigured-conventional-commits') | ||
|
||
/* | ||
Commands executed during release. | ||
It also set an environment variable "release" indicating that the release was successful. | ||
*/ | ||
const publishCommands = ` | ||
git tag -a -f \${nextRelease.version} \${nextRelease.version} -F CHANGELOG.md || exit 2 | ||
git push --force origin \${nextRelease.version} || exit 3 | ||
echo "release_status=released" >> $GITHUB_ENV | ||
echo "CONTAINER_VERSION="\${nextRelease.version} >> $GITHUB_ENV | ||
` | ||
// Only release on branch main | ||
const releaseBranches = ["main"] | ||
|
||
config.branches = releaseBranches | ||
|
||
config.plugins.push( | ||
// Custom release commands | ||
["@semantic-release/exec", { | ||
"publishCmd": publishCommands, | ||
}], | ||
"@semantic-release/github", | ||
"@semantic-release/git", | ||
) | ||
|
||
// JS Semantic Release configuration must export the JS configuration object | ||
module.exports = config |