Initial gradle build #1067
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build java package | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
push: # Apply to all branches | |
env: | |
CHANGELIST: -SNAPSHOT | |
RELEASE_VERSION: 0.0.0 | |
jobs: | |
test-java-snapshot: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: read | |
steps: | |
# Run `git checkout` | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Retrieve current version from gradle.properties | |
run: | | |
echo RELEASE_VERSION=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{print $2}') >> $GITHUB_ENV | |
echo GIT_HASH_SHORT=$(git rev-parse --short "$GITHUB_SHA") >> $GITHUB_ENV | |
- name: Remove SNAPSHOT suffix for release | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
echo CHANGELIST= >> $GITHUB_ENV | |
- name: Add git hash to snapshot release | |
if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/v') | |
run: | | |
echo CHANGELIST=${{ env.CHANGELIST }}.${{ env.GIT_HASH_SHORT }} >> $GITHUB_ENV | |
- name: Run headless test | |
uses: GabrielBB/xvfb-action@v1 | |
with: | |
run: ./gradlew check -Prevision=${{ env.RELEASE_VERSION }} -Pchangelist=${{ env.CHANGELIST }} | |
working-directory: ./ #optional | |
options: #optional | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: retrieve jre cache | |
id: jre-cache | |
uses: actions/cache@v3 | |
with: | |
path: sdccc/build/jre | |
key: jre-cache | |
- name: Build package and download license information | |
run: | | |
./gradlew build -x test -Prevision=${{ env.RELEASE_VERSION }} -Pchangelist=${{ env.CHANGELIST }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Collect executable artifacts | |
run: | | |
mkdir sdccc/build/zip | |
cp -r sdccc/build/lib sdccc/build/zip/ | |
cp -r sdccc/build/jre sdccc/build/zip/ | |
cp -r sdccc/build/reports/dependency-license/downloaded-licenses/ sdccc/build/zip/lib/ | |
cp -r sdccc/build/reports/dependency-license/index.xml sdccc/build/zip/lib/ | |
cp -r configuration sdccc/build/zip/ | |
cp sdccc/build/launch4j/SDCcc-*.exe sdccc/build/zip/ | |
cp README.md sdccc/build/zip/ | |
- name: Set zip file name for release | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
echo ZIP_FILE_NAME=SDCcc-${{ env.RELEASE_VERSION }}${{ env.CHANGELIST }}-executable-win64.zip >> $GITHUB_ENV | |
- name: Install zip | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: montudor/action-zip@v1 | |
- name: Zip executable | |
if: startsWith(github.ref, 'refs/tags/') | |
working-directory: sdccc/build/zip | |
run: | | |
zip -qq -r ${{ env.ZIP_FILE_NAME }} . | |
- name: Zip test results | |
if: startsWith(github.ref, 'refs/tags/') | |
working-directory: sdccc/build/ | |
run: | | |
zip -qq -r test-results.zip reports/tests reports/checkstyle reports/spotbugs reports/detekt | |
- name: Attach artifacts to snapshot | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
CHANGELOG.md | |
sdccc/build/zip/${{ env.ZIP_FILE_NAME }} | |
sdccc/build/test-results.zip | |
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') }} | |
body_path: CHANGELOG.md |