Skip to content

Commit

Permalink
Better workflows for building ZBGT (#136)
Browse files Browse the repository at this point in the history
* Better build workflows

* Use build cache
Add NIGHTLY-hash to nightly builds
  • Loading branch information
Zorbatron authored Jan 20, 2025
1 parent 24c40ac commit 780f210
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Adapted from https://github.com/GregTechCEu/GregTech-Modern/blob/1.20.1/.github/workflows/build-on-push.yml
name: Build pull request on push
on:
pull_request:
paths: ['**']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build ZBGT
runs-on: ubuntu-latest
env:
VERSION_SUFFIX: "PR-${{ github.event.number }}"

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
fetch-depth: 0

- name: Setup Build
uses: ./.github/actions/build_setup

- name: Build Project
run: ./gradlew build --build-cache

- name: Rename Jars
run: for file in build/libs/*; do mv "$file" "${file/.jar/-${{ env.VERSION_SUFFIX }}.jar}"; done;

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Built Jars
path: |
./build/libs/*.jar
if-no-files-found: error
compression-level: 0
14 changes: 10 additions & 4 deletions .github/workflows/build.yml → .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# CI/CD: Build ZBGT on Commit
name: Build ZBGT
name: ZBGT Nightly
on:
push:
pull_request:
workflow_dispatch:
branches: ['main']
paths: ['src/**', '**/*.gradle', 'gradle.properties']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -21,11 +21,17 @@ jobs:
ref: ${{ inputs.tag }}
fetch-depth: 0

- name: Version Suffix
run: echo "VERSION_SUFFIX=NIGHTLY-$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Setup Build
uses: ./.github/actions/build_setup

- name: Build Project
run: ./gradlew build
run: ./gradlew build --build-cache

- name: Rename Jars
run: for file in build/libs/*; do mv "$file" "${file/.jar/-${{ env.VERSION_SUFFIX }}.jar}"; done;

- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down

0 comments on commit 780f210

Please sign in to comment.