Skip to content

Commit

Permalink
ci: [#28] add semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
davdarras committed Feb 22, 2023
1 parent ee0af83 commit f979ac2
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 7 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ci-develop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Create beta version

on:
push:
branches:
- v2-develop

jobs:
release-rc:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 18
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: setup semantic-release
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/exec semantic-release/git semantic-release/release-notes-generator @saithodev/semantic-release-backmerge conventional-changelog-conventionalcommits
- name: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release

build:
needs: release-rc
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.version-step.outputs.pe-version }}
steps:
- uses: actions/checkout@v3
with:
ref: v2-develop

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"

- name: Get current version
id: version-step
run: echo "pe-version=$(mvn -f pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT

- name: Print PE Version
run: echo ${{ steps.version-step.outputs.pe-version }}

- name: Build PE
run: mvn package --no-transfer-progress

- name: Upload PE jar
uses: actions/upload-artifact@v3
with:
name: pe-jar
path: target/*.jar

docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: v2-develop
- name: Download PE jar
uses: actions/download-artifact@v3
with:
name: pe-jar
path: target/

- name: Publish to Docker Hub
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: inseefr/public-enemy-back-office
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
default_branch: v2-develop
tags: latest
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
name: V2 Build Docker
name: Create production version

on: push

env:
PE_BRANCH: feature/ci
on:
push:
branches:
- v2-main

jobs:
release:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 18
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: setup semantic-release
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/exec semantic-release/git semantic-release/release-notes-generator @saithodev/semantic-release-backmerge conventional-changelog-conventionalcommits
- name: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
build:
needs: release
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.version-step.outputs.pe-version }}
steps:
- uses: actions/checkout@v3
with:
ref: v2-main

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -21,7 +48,7 @@ jobs:

- name: Get current version
id: version-step
run: echo "::set-output name=pe-version::$(mvn -f pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)"
run: echo "pe-version=$(mvn -f pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT

- name: Print PE Version
run: echo ${{ steps.version-step.outputs.pe-version }}
Expand All @@ -40,6 +67,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: v2-main

- name: Download PE jar
uses: actions/download-artifact@v3
Expand All @@ -53,5 +82,5 @@ jobs:
name: inseefr/public-enemy-back-office
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
default_branch: feature/ci
default_branch: v2-main
tags: ${{ needs.build.outputs.release-version }}
68 changes: 68 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"branches": [
"v2-main",
{
"name": "v2-develop",
"prerelease": "beta"
}
],
"tagFormat": "${version}",
"repositoryUrl": "https://github.com/InseeFr/Public-Enemy-Back-Office",
"debug": "true",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"writerOpts": {
"groupBy": "type",
"commitGroupsSort": "title",
"commitsSort": "header"
},
"linkCompare": true,
"linkReferences": true
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# Semantic Versioning Changelog"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "mvn versions:set -DnewVersion=${nextRelease.version} --no-transfer-progress"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"pom.xml"
],
"message": "chore(release): Bumped to version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github",
[
"@saithodev/semantic-release-backmerge",
{
"branches": [
{
"from": "v2-main",
"to": "v2-develop"
}
]
}
]
]
}

0 comments on commit f979ac2

Please sign in to comment.