From 9ab0bd0a8d1b64931325e5b0099db445dc715d04 Mon Sep 17 00:00:00 2001 From: Abhinay Agarwal Date: Thu, 4 May 2023 13:58:46 +0530 Subject: [PATCH] Use Github Actions to build and release (#143) --- .ci/deploy-snapshot.sh | 10 ---- .ci/release.sh | 22 --------- .github/workflows/build.yml | 48 ++++++++++++++++++ .github/workflows/release.yml | 49 +++++++++++++++++-- .github/workflows/tests.yml | 16 ------ .travis.yml | 40 --------------- .../openjfx/gradle/JavaFXPluginSmokeTest.java | 6 +-- 7 files changed, 97 insertions(+), 94 deletions(-) delete mode 100644 .ci/deploy-snapshot.sh delete mode 100644 .ci/release.sh create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.ci/deploy-snapshot.sh b/.ci/deploy-snapshot.sh deleted file mode 100644 index a8316db..0000000 --- a/.ci/deploy-snapshot.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# Find project version -ver=$(./gradlew properties -q | grep "version:" | awk '{print $2}') - -# deploy if snapshot found -if [[ $ver == *"SNAPSHOT"* ]] -then - ./gradlew publish -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD -fi \ No newline at end of file diff --git a/.ci/release.sh b/.ci/release.sh deleted file mode 100644 index 61f7bc8..0000000 --- a/.ci/release.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -./gradlew publishPlugins -Pgradle.publish.key=$PUBLISH_KEY -Pgradle.publish.secret=$PUBLISH_SECRET - -# Update version by 1 -newVersion=${TRAVIS_TAG%.*}.$((${TRAVIS_TAG##*.} + 1)) - -# Update README with the latest released version -sed -i "0,/id 'org.openjfx.javafxplugin' version '.*'/s//id 'org.openjfx.javafxplugin' version '$TRAVIS_TAG'/" README.md -sed -i "0,/id(\"org.openjfx.javafxplugin\") version \".*\"/s//id(\"org.openjfx.javafxplugin\") version \"$TRAVIS_TAG\"/" README.md -sed -i "0,/'org.openjfx:javafx-plugin:.*'/s//'org.openjfx:javafx-plugin:$TRAVIS_TAG'/" README.md -sed -i "0,/\"org.openjfx:javafx-plugin:.*\"/s//\"org.openjfx:javafx-plugin:$TRAVIS_TAG\"/" README.md -git commit README.md -m "Use latest release v$TRAVIS_TAG in README" - -# Replace first occurrence of -# version 'TRAVIS_TAG' -# with -# version 'newVersion-SNAPSHOT' -sed -i "0,/^version '$TRAVIS_TAG'/s//version '$newVersion-SNAPSHOT'/" build.gradle - -git commit build.gradle -m "Upgrade version to $newVersion-SNAPSHOT" --author "Github Bot " -git push https://gluon-bot:$GITHUB_PASSWORD@github.com/openjfx/javafx-gradle-plugin HEAD:master \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..358e692 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,48 @@ +name: Build + +on: + push: + branches: + - master + pull_request: + +jobs: + gradlevalidation: + name: "Validate Gradle Wrapper" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + + - name: Build and verify project + run: | + export DISPLAY=:90 + Xvfb -ac :90 -screen 0 1280x1024x24 > /dev/null 2>&1 & + ./gradlew clean build -i + + - name: Publish Snapshots + if: github.ref == 'refs/heads/master' + run: | + # Find project version + ver=$(./gradlew properties -q | grep "version:" | awk '{print $2}') + # deploy if snapshot found + if [[ $ver == *"SNAPSHOT"* ]] + then + ./gradlew publish -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD + fi + shell: bash + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 401976c..aca7b69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,11 +6,54 @@ on: jobs: build: - name: release-notes + name: release runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + + - name: Build and verify project + run: | + export DISPLAY=:90 + Xvfb -ac :90 -screen 0 1280x1024x24 > /dev/null 2>&1 & + ./gradlew clean build -i + + - name: Publish to Gradle plugin repository + id: deploy + if: github.ref == 'refs/heads/master' + run: | + ./gradlew publishPlugins -Pgradle.publish.key=$PUBLISH_KEY -Pgradle.publish.secret=$PUBLISH_SECRET + shell: bash + env: + PUBLISH_KEY: ${{ secrets.PUBLISH_KEY }} + PUBLISH_SECRET: ${{ secrets.PUBLISH_SECRET }} + + - name: Commit next development version + if: steps.deploy.outputs.exit_code == 0 + run: | + TAG=${GITHUB_REF/refs\/tags\//} + # Update README with the latest released version + sed -i "0,/id 'org.openjfx.javafxplugin' version '.*'/s//id 'org.openjfx.javafxplugin' version '$TAG'/" README.md + sed -i "0,/id(\"org.openjfx.javafxplugin\") version \".*\"/s//id(\"org.openjfx.javafxplugin\") version \"$TAG\"/" README.md + sed -i "0,/'org.openjfx:javafx-plugin:.*'/s//'org.openjfx:javafx-plugin:$TAG'/" README.md + sed -i "0,/\"org.openjfx:javafx-plugin:.*\"/s//\"org.openjfx:javafx-plugin:$TAG\"/" README.md + git commit README.md -m "Use latest release v$TAG in README" + # Update project version + newVersion=${TAG%.*}.$((${TAG##*.} + 1)) + echo "Update project version to next snapshot version" + sed -i "0,/^version '$TAG'/s//version '$newVersion-SNAPSHOT'/" build.gradle + git commit build.gradle -m "Prepare development of $newVersion" --author "Github Bot " + git push https://gluon-bot:$PAT@github.com/openjfx/javafx-gradle-plugin HEAD:master + env: + PAT: ${{ secrets.GITHUB_TOKEN }} + - name: Create GitHub release uses: softprops/action-gh-release@v1 with: - token: ${{ secrets.PAT }} - generate_release_notes: true \ No newline at end of file + generate_release_notes: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 7afa110..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Validate Gradle Wrapper - -on: - push: - branches: - - master - pull_request: - # always run on pull requests - -jobs: - gradlevalidation: - name: "Validate Gradle Wrapper" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: gradle/wrapper-validation-action@v1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9822942..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -dist: trusty - -sudo: required - -language: java - -jdk: openjdk11 - -install: true - -cache: - directories: - - $HOME/.m2 - - $HOME/.gradle - -before_install: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - - sleep 3 - -before_script: - - ./gradlew --version - -script: - - TERM=dumb ./gradlew build --scan - -deploy: - # Deploy snapshots on every commit made to master - - provider: script - script: bash .ci/deploy-snapshot.sh - skip_cleanup: true - on: - branch: master - - # Deploy releases on every tag push - - provider: script - script: bash .ci/release.sh - skip_cleanup: true - on: - tags: true diff --git a/src/test/java/org/openjfx/gradle/JavaFXPluginSmokeTest.java b/src/test/java/org/openjfx/gradle/JavaFXPluginSmokeTest.java index f9d89b0..277540c 100644 --- a/src/test/java/org/openjfx/gradle/JavaFXPluginSmokeTest.java +++ b/src/test/java/org/openjfx/gradle/JavaFXPluginSmokeTest.java @@ -44,7 +44,7 @@ void smokeTestModular() { var result = GradleRunner.create() .withProjectDir(new File("test-project")) .withGradleVersion("6.0.1") - .withArguments("clean", "build", "run", "--stacktrace") + .withArguments("clean", "build", "run", "--stacktrace", "--refresh-dependencies") .forwardOutput() .build(); @@ -56,7 +56,7 @@ void smokeTestNonModular() { var result = GradleRunner.create() .withProjectDir(new File("test-project")) .withGradleVersion("6.0.1") - .withArguments("clean", "build", "run", "--stacktrace") + .withArguments("clean", "build", "run", "--stacktrace", "--refresh-dependencies") .forwardOutput() .build(); @@ -68,7 +68,7 @@ void smokeTestTransitive() { var result = GradleRunner.create() .withProjectDir(new File("test-project")) .withGradleVersion("6.0.1") - .withArguments("clean", "build", "run", "--stacktrace") + .withArguments("clean", "build", "run", "--stacktrace", "--refresh-dependencies") .forwardOutput() .build();