Skip to content

Commit

Permalink
#25 test releasing possibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
kasramp committed Apr 29, 2023
1 parent bd91f00 commit 8de2042
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 49 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build_and_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Tag

on:
push:
branches:
- develop
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-${{ github.ref_name }}-sonar
restore-keys: ${{ runner.os }}-${{ github.ref_name }}-sonar
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=kasramp-github -Dsonar.projectKey=Eris
- uses: actions/checkout@v3
- name: Set last commit
shell: bash
run: |
echo "::set-output name=LAST_COMMIT::$(git log -n 1)"
id: version
- name: Tag
shell: bash
env:
VERSION: ${{ steps.version.outputs.LAST_COMMIT }}
EMAIL: ${{ secrets.EMAIL }}
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pwd ${GITHUB_WORKSPACE}
chmod +x "${GITHUB_WORKSPACE}/util/release.sh"
./${GIHUB_WORKSPACE}/util/release.sh
54 changes: 7 additions & 47 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,15 @@
name: CI/CD pipeline
name: Do release

on:
push:
branches:
- develop
- master
tags:
- "^(?!.*-beta).*$"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: develop
fetch-depth: 0
- name: Cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=kasramp-github -Dsonar.projectKey=Eris
- uses: actions/checkout@v3
- name: Set last commit
shell: bash
run: |
echo "::set-output name=LAST_COMMIT::$(git log -n 1)"
id: version
- name: Checkout
uses: actions/checkout@v3
- name: Release
shell: bash
env:
VERSION: ${{ steps.version.outputs.LAST_COMMIT }}
EMAIL: ${{ secrets.EMAIL }}
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pwd ${GITHUB_WORKSPACE}
chmod +x "${GITHUB_WORKSPACE}/util/release.sh"
./${GIHUB_WORKSPACE}/util/release.sh
uses: softprops/action-gh-release@v1
6 changes: 4 additions & 2 deletions util/release.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/bin/bash
set -ev

if [ "$LAST_COMMIT" != *"maven-release-plugin"* ]; then
if [[ "$LAST_COMMIT" != *"maven-release-plugin"* ]]; then
git config --global user.email $EMAIL
git config --global user.name $USERNAME
git symbolic-ref HEAD refs/heads/$(git branch --show-current)
git symbolic-ref HEAD
if [ $(git branch --show-current) == "develop" ]; then
mvn -B clean release:clean release:prepare release:perform -Dusername=$USERNAME -Dpassword=$TOKEN -DtagNameFormat=@{artifactId}-beta-@{version} -Darguments="-Dmaven.deploy.skip=true"
else
mvn -B clean release:clean release:prepare release:perform -Dusername=$USERNAME -Dpassword=$TOKEN -Darguments="-Dmaven.deploy.skip=true"
mvn -B clean release:clean release:prepare release:perform -Dusername=$USERNAME -Dpassword=$TOKEN -Darguments="-Dmaven.deploy.skip=true" &&
git fetch origin develop && git merge origin/master &&
git push https://$USERNAME:$TOKEN@github.com/kasramp/Eris.git HEAD:develop
fi
fi

0 comments on commit 8de2042

Please sign in to comment.