Skip to content

Commit

Permalink
reusable-build.yml umstellen
Browse files Browse the repository at this point in the history
  • Loading branch information
tobidope committed Jan 28, 2025
1 parent 3c4e45e commit 41fa2b5
Showing 1 changed file with 13 additions and 75 deletions.
88 changes: 13 additions & 75 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Reusable build steps

on:
workflow_call:
workflow_dispatch:

jobs:
setup-java-and-cache:
Expand All @@ -14,84 +15,21 @@ jobs:
distribution: 'temurin'
architecture: x64

- name: Set env
id: setenvs
run: |
jameica_tag=$(git ls-remote --refs --tags --sort="-v:refname" https://github.com/willuhn/jameica.git V_\* | head -1 | cut -f 2 | cut -d / -f 3)
echo "jameica_tag=${jameica_tag}" >> $GITHUB_ENV
hibiscus_tag=$(git ls-remote --refs --tags --sort="-v:refname" https://github.com/willuhn/hibiscus.git V_\* | head -1 | cut -f 2 | cut -d / -f 3)
echo "hibiscus_tag=${hibiscus_tag}" >> $GITHUB_ENV
echo "### jameica_tag: ${jameica_tag} | hibiscus_tag: ${hibiscus_tag}"
- name: Restore cached tags and folders
id: cache-tags-jars
uses: actions/cache@v4
with:
path: |
./cached-tags
jameica
hibiscus
key: ${{ runner.os }}-${{ github.repository_id }}

- name: Load cached tags
id: load-cache
run: |
if [ -f ./cached-tags/jameica_tag ]; then
cached_jameica_tag=$(cat ./cached-tags/jameica_tag)
echo "cached_jameica_tag=${cached_jameica_tag}" >> $GITHUB_ENV
else
echo "cached_jameica_tag=" >> $GITHUB_ENV
fi
if [ -f ./cached-tags/hibiscus_tag ]; then
cached_hibiscus_tag=$(cat ./cached-tags/hibiscus_tag)
echo "cached_hibiscus_tag=${cached_hibiscus_tag}" >> $GITHUB_ENV
else
echo "cached_hibiscus_tag=" >> $GITHUB_ENV
fi
echo "### cached_jameica_tag: ${cached_jameica_tag} | cached_hibiscus_tag: ${cached_hibiscus_tag}"
- name: Checkout jameica
if: ${{ env.cached_jameica_tag != env.jameica_tag }}
- name: Checkout
uses: actions/checkout@v4
with:
repository: willuhn/jameica
path: jameica
ref: ${{ env.jameica_tag }}

- name: Build jameica jar
if: ${{ env.cached_jameica_tag != env.jameica_tag }}
working-directory: ./
run: |
ant -noinput -buildfile jameica/build/build.xml jar
find jameica/releases/ -type f -name jameica.jar -exec cp {} jameica/releases/jameica-lib.jar \;
- name: Checkout hibiscus
if: ${{ env.cached_hibiscus_tag != env.hibiscus_tag }}
uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache/restore@v4
with:
repository: willuhn/hibiscus
path: hibiscus
ref: ${{ env.hibiscus_tag }}
path: ~/.m2/repository
key: cache-{{ hashFiles('**/pom.xml', 'setup-build.xml') }}

- name: Build hibiscus jar
if: ${{ env.cached_hibiscus_tag != env.hibiscus_tag }}
working-directory: ./
run: |
ant -noinput -buildfile hibiscus/build/build.xml jar
find hibiscus/releases/ -type f -name hibiscus.jar -exec cp {} hibiscus/releases/hibiscus-lib.jar \;
- name: Run setup-build.xml
run: mvn --batch --file setup-build.xml clean initialize

- name: Create cache files and needed folders
run: |
mkdir -p ./cached-tags
echo "${{ env.jameica_tag }}" > ./cached-tags/jameica_tag
echo "${{ env.hibiscus_tag }}" > ./cached-tags/hibiscus_tag
- name: Cache tags and folders
uses: actions/cache@v4
if: always()
- name: Save cache
uses: actions/cache/save@4
with:
path: |
./cached-tags
jameica
hibiscus
key: ${{ runner.os }}-${{ github.repository_id }}
path: ~/.m2/repository
key: cache-{{ hashFiles('**/pom.xml', 'setup-build.xml') }}

0 comments on commit 41fa2b5

Please sign in to comment.