Skip to content

Commit

Permalink
CI and release workflow updates: (#104)
Browse files Browse the repository at this point in the history
- On CI workflow code version is extracted from gradle.properties and publish-to-sonatype-snapshot job is executed when this version ends with '-SNAPSHOT'
- On release workflow publication to maven is happening only if released tag is matching code version as set in gradle.properties file

Co-authored-by: VAFEIADIS Nikos <[email protected]>
  • Loading branch information
vafeini and VAFEIADIS Nikos authored Nov 6, 2023
1 parent c8b33de commit ea38a69
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ on:
types: [opened, reopened]
push:

permissions:
contents: read
packages: read

jobs:
build-gradle:
name: Build
runs-on: ubuntu-latest
runs-on: ubuntu-latest
outputs:
code-version: ${{ steps.extract.outputs.CODE_VERSION }}
steps:
- name: Checkout project sources
uses: actions/checkout@v4
Expand All @@ -28,11 +26,14 @@ jobs:
arguments: build --full-stacktrace
env:
CI: true
- id: extract
name: Extract code version from gradle.properties
run: echo "CODE_VERSION=$(awk -F= '$1~/version/{print $2}' gradle.properties)" >> $GITHUB_OUTPUT

publish-to-sonatype-snapshot:
name: Publish to sonatype.org (SNAPSHOT)
needs: [ build-gradle ]
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release')) && github.repository_owner == 'eu-digital-identity-wallet'
if: github.event_name != 'pull_request' && endsWith(needs.build-gradle.outputs.code-version, '-SNAPSHOT') && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release')) && github.repository_owner == 'eu-digital-identity-wallet'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ on:
release:
types: [released]
jobs:
extract-code-version:
name: Extract code version
runs-on: ubuntu-latest
outputs:
code-version: ${{ steps.extract.outputs.CODE_VERSION }}
steps:
- name: Checkout project sources
uses: actions/checkout@v4
- id: extract
name: Extract code version from gradle.properties
run: echo "CODE_VERSION=$(awk -F= '$1~/version/{print $2}' gradle.properties)" >> $GITHUB_OUTPUT

publish-to-sonatype:
name: Publish to sonatype.org
if: github.repository_owner == 'eu-digital-identity-wallet' && startsWith(github.ref, 'refs/tags')
needs: [ extract-code-version ]
if: github.repository_owner == 'eu-digital-identity-wallet' && startsWith(github.ref, 'refs/tags') && format('v{0}', needs.extract-code-version.outputs.code-version) == github.ref_name
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down

0 comments on commit ea38a69

Please sign in to comment.