From 1130dbf2831ec96d4d0b73c5f1cc57793891f21f Mon Sep 17 00:00:00 2001 From: Stian Kristoffersen Date: Fri, 7 May 2021 11:40:13 +0200 Subject: [PATCH] Use GitHub Actions for build and release (#96) * Use GitHub Actions for build and release * Add empty properties and run tests --- .github/workflows/build.yml | 21 ++++++++++++++++++ .github/workflows/release.yml | 41 +++++++++++++++++++++++++++++++++++ cli/build.gradle | 4 ++-- script/installjdk | 1 + 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a555baf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +name: Build gradle project + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Install JDK + run: ./script/installjdk + - name: Build with Gradle + run: ./gradlew -PossrhUsername="" -PossrhPassword="" test + env: + JAVA_HOME: /home/runner/corretto-8/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7288d30 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: Create release of CLI + +on: + push: + tags: + - '*' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Install JDK + run: ./script/installjdk + - name: Build with Gradle + run: ./gradlew -PossrhUsername="" -PossrhPassword="" cliTar + env: + JAVA_HOME: /home/runner/corretto-8/ + GITHUB_REF: ${{ github.ref }} + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./cli/build/distributions/strongbox-cli.tar.gz + asset_name: strongbox-cli.tar.gz + asset_content_type: application/x-gzip diff --git a/cli/build.gradle b/cli/build.gradle index 902af33..0defa2f 100644 --- a/cli/build.gradle +++ b/cli/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'nebula.deb' apply plugin: 'signing' mainClassName = 'com.schibsted.security.strongbox.cli.StrongboxCLI' -version = getenv('TRAVIS_TAG') ? getenv('TRAVIS_TAG') : "0.0.1"; +version = getenv('GITHUB_REF') ? getenv('GITHUB_REF').replace("refs/tags/","") : "0.0.1"; dependencies { compile project(':sdk') @@ -118,7 +118,7 @@ task cliRpm(type: Rpm, dependsOn: "installDist") { task cliTar(type: Tar, dependsOn: "installDist") { from(installDist) into('strongbox-cli') - archiveName = 'strongbox-cli-' + version + '.tar.gz' + archiveName = 'strongbox-cli.tar.gz' extension = 'tar.gz' compression = Compression.GZIP diff --git a/script/installjdk b/script/installjdk index c10321b..85d7796 100755 --- a/script/installjdk +++ b/script/installjdk @@ -17,3 +17,4 @@ cd $CWD export JAVA_HOME=$BASE export PATH=$JAVA_HOME/bin:$PATH +echo "$JAVA_HOME/bin" >> $GITHUB_PATH