Skip to content

Commit

Permalink
test: build as jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
grigoriev committed Aug 2, 2024
1 parent 2b68cd7 commit 6d7db39
Showing 1 changed file with 23 additions and 35 deletions.
58 changes: 23 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: ['**/**']
jobs:
produce-packages:
build:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -21,9 +21,9 @@ jobs:
java-version: 17
cache: maven
gpg-private-key: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PRIVATE_KEY }}
- name: Cache
id: cache
uses: actions/cache@v3
- name: Prepare Cache
id: prepare-cache
uses: actions/cache@v4
with:
path: |
/home/runner/.m2
Expand Down Expand Up @@ -79,69 +79,57 @@ jobs:
run: cat /home/runner/.m2/settings.xml
- name: Build with Maven
run: mvn --batch-mode clean package
- name: Extract artefact version
id: artefact_version
run: echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- name: Store project version
id: project_version
run: echo "project_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- name: Store cache key
id: cache_key
run: echo "${{ runner.os }}-mvn-${{ hashFiles('**/pom.xml') }}" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.artefact_version.outputs.version }}
project_version: ${{ steps.project_version.outputs.project_version }}
cache_key: ${{ steps.cache_key.outputs.cache_key }}

# deploy to maven-central
# deploy to Maven Central
deploy-maven-central:
needs: produce-packages
needs: build
runs-on: ubuntu-latest
# if: ${{ endsWith(needs.produce-packages.outputs.version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
if: ${{ endsWith(needs.build.outputs.project_version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
permissions:
contents: read
packages: write
env:
GITHUB_TOKEN: ${{ github.token }}
MARKDOWN2HTML_MAVEN_PLUGIN_FAIL_ON_ERROR: true
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up JDK and Maven
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
with:
distribution: adopt
java-version: 17
cache: maven
gpg-private-key: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PRIVATE_KEY }}
- name: Cache
id: cache
uses: actions/cache@v3
- name: Restore Cache
id: restore-cache
uses: actions/cache@v4
with:
path: |
/home/runner/.m2
/home/runner/work
key: ${{ runner.os }}-mvn-${{ hashFiles('**/pom.xml') }}
key: ${{ needs.build.outputs.cache_key }}
- name: Publish to Maven Central
run: mvn --batch-mode -DskipTests=true -Dmaven.javadoc.skip=true package -P gpg-sign -P nexus-staging

# deploy to GitHub Packages
deploy-github-packages:
needs: produce-packages
needs: build
runs-on: ubuntu-latest
# if: ${{ endsWith(needs.produce-packages.outputs.version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
# if: ${{ endsWith(needs.build.outputs.version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
permissions:
contents: read
packages: write
env:
GITHUB_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up JDK and Maven
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
with:
distribution: adopt
java-version: 17
cache: maven
gpg-private-key: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PRIVATE_KEY }}
- name: Cache
id: cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
/home/runner/.m2
/home/runner/work
key: ${{ runner.os }}-mvn-${{ hashFiles('**/pom.xml') }}
key: ${{ needs.build.outputs.cache_key }}
- name: Publish to GitHub Packages
run: mvn --batch-mode -DskipTests=true -Dmaven.javadoc.skip=true package -P gpg-sign -P deploy-github-packages

0 comments on commit 6d7db39

Please sign in to comment.