Skip to content

Commit

Permalink
Merge pull request #106 from stewartbryson/stewart
Browse files Browse the repository at this point in the history
Implement release-drafter.
  • Loading branch information
stewartbryson authored Oct 27, 2023
2 parents c59a989 + 5becfd3 commit 33627a6
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 156 deletions.
69 changes: 46 additions & 23 deletions .github/workflows/gradle-pr.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,86 @@
name: Run Gradle on PRs
name: Gradle Pull Request

on:
pull_request
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
# pull_request_target:
# types: [opened, reopened, synchronize]

env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}

jobs:
gradle_build:
gradle-pr:
permissions:
# write permission is required to create a GitHub release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
# for publish-tests
checks: write
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

# - id: echo_environment
# run: ./echo-environment.sh
# name: "Echo environment"
# shell: bash

- id: gradle_properties
- name: Write gradle.properties file
id: gradle-properties
run: |
mkdir -p $HOME/.gradle
echo "$GRADLE_PROPERTIES" > $HOME/.gradle/gradle.properties
name: 'Write gradle.properties file'
shell: bash
env:
GRADLE_PROPERTIES: ${{secrets.GRADLE_PROPERTIES}}

- id: credentials_file
- name: Write .snowflake/config.toml file
id: credentials-file
run: |
mkdir -p $HOME/.snowflake
echo "$SNOW_CONFIG" > $HOME/.snowflake/config.toml
name: 'Write .snowflake/config.toml file'
shell: bash
env:
SNOW_CONFIG: ${{secrets.SNOW_CONFIG}}

- id: google_auth
name: 'Authenticate to Google Cloud'
- name: Authenticate to Google Cloud
id: google-auth
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'

- id: gradle_build
name: Gradle build and test
- name: Gradle build and test
id: gradle-build
uses: gradle/[email protected]
with:
arguments: build validatePlugin functionalTest integrationTest buildDashboard --scan -S
cache-read-only: ${{ github.base_ref == 'main' }}

- id: publish_tests
name: Publish tests
- name: Publish tests
id: publish-tests
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/**/TEST-*.xml'

run_example:
- name: Create a draft release from PR.
id: release-draft
uses: release-drafter/release-drafter@v5
with:
commitish: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run-example:
#if: ${{ false }} # disable for now
runs-on: ubuntu-latest

Expand All @@ -70,20 +93,20 @@ jobs:
# Should really make these reusable
- uses: actions/checkout@v3

- id: gradle_properties
- name: Write gradle.properties file
id: gradle-properties
run: |
mkdir -p $HOME/.gradle
echo "$GRADLE_PROPERTIES" > $HOME/.gradle/gradle.properties
name: 'Write gradle.properties file'
shell: bash
env:
GRADLE_PROPERTIES: ${{secrets.GRADLE_PROPERTIES}}

- id: credentials_file
- name: Write .snowflake/config.toml file
id: credentials-file
run: |
mkdir -p $HOME/.snowflake
echo "$SNOW_CONFIG" > $HOME/.snowflake/config.toml
name: 'Write .snowflake/config.toml file'
shell: bash
env:
SNOW_CONFIG: ${{secrets.SNOW_CONFIG}}
Expand Down
109 changes: 0 additions & 109 deletions .github/workflows/gradle-publish.yml

This file was deleted.

86 changes: 86 additions & 0 deletions .github/workflows/gradle-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Gradle Release

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}

jobs:
gradle-release:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Write gradle.properties file
id: gradle-properties
run: |
mkdir -p $HOME/.gradle
echo "$GRADLE_PROPERTIES" > $HOME/.gradle/gradle.properties
shell: bash
env:
GRADLE_PROPERTIES: ${{secrets.GRADLE_PROPERTIES}}

- name: Write .snowflake/config.toml file
id: credentials-file
run: |
mkdir -p $HOME/.snowflake
echo "$SNOW_CONFIG" > $HOME/.snowflake/config.toml
shell: bash
env:
SNOW_CONFIG: ${{secrets.SNOW_CONFIG}}

- name: Authenticate to Google Cloud
id: google-auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}

- name: Set Values
id: set-values
run: |
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Echo Version
id: echo-version
run: |
echo ${{ steps.set-values.outputs.version }}
- name: Gradle publish
id: gradle-publish
uses: gradle/[email protected]
with:
arguments: build validatePlugin publish examples buildDashboard -Pversion=${{ steps.set-values.outputs.version }} -S --scan

- name: Publish tests
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/**/TEST-*.xml'

- name: Upload binaries to release
id: upload-binaries
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: '**/build/libs/*.jar'
asset_name: gradle-plugin
tag: ${{ github.ref }}
overwrite: true
file_glob: true

- name: Update Documentation
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Updating README and examples.
branch: main
file_pattern: 'README.md examples/*.gradle'
status_options: '--untracked-files=no'
23 changes: 0 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins {
id "com.github.ben-manes.versions" version "0.49.0"
id "pl.allegro.tech.build.axion-release" version "1.15.5"
id "com.github.breadmoirai.github-release" version "2.4.1"
id "build-dashboard"
id 'idea'
}
Expand All @@ -13,7 +11,6 @@ allprojects {
mavenCentral()
gradlePluginPortal()
}
project.version = scmVersion.version
}

if (hasProperty('buildScan')) {
Expand All @@ -23,26 +20,6 @@ if (hasProperty('buildScan')) {
}
}

scmVersion {
tag {
prefix = 'v'
versionSeparator = ''
}
ignoreUncommittedChanges = true
localOnly = true
useHighestVersion = true
}

githubRelease {
token project.findProperty('githubToken').toString()
owner 'stewartbryson'
repo rootProject.name
overwrite true
generateReleaseNotes true
//releaseAssets 'plugin/build/libs'
//dryRun true
}

import org.apache.tools.ant.filters.ReplaceTokens
tasks.register('copyReadme', Copy) {
group 'documentation'
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ tasks.register("publishDocs") {
mustRunAfter tasks.publishPlugins
}

tasks.publish.dependsOn tasks.publishPlugins
tasks.publish.dependsOn tasks.publishPlugins, tasks.publishDocs
1 change: 1 addition & 0 deletions plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
internalStage=upload
s3Stage=s3_maven
gcsStage=gcs_maven
version=1.0.0

0 comments on commit 33627a6

Please sign in to comment.