Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reusable workflows #78

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"

53 changes: 53 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

name-template: 'v$NEXT_MINOR_VERSION'
tag-template: 'v$NEXT_MINOR_VERSION'
exclude-labels:
- 'skipReleaseNotes'
categories:
- title: ':green_book: Notable Changes'
labels:
- 'notableChanges'
- title: '🚀 New Features'
labels:
- 'TypeEnhancement'
- 'TypeTest'
- title: '🐛 Bug Fixes 🛠'
labels:
- 'TypeBug'
- title: '💥 Breaking Changes'
labels:
- 'breakingChanges'
- title: '🤖 Security Driver and Other Updates'
collapse-after: 5
labels:
- 'sdou'
- 'dependencies'
- title: '👏 New Contributors'
labels:
- 'newContributors'


change-template: '- (#$NUMBER) $TITLE @$AUTHOR '
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'feature'
- 'enhancement'
- 'patch'
- 'bugfix'
- 'sdou'
default: minor
template: |
## Changes

$CHANGES

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$REPOSITORY-$RESOLVED_VERSION

12 changes: 12 additions & 0 deletions .github/workflows/attach-artifact-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Attach Artifact to Release

on:
pull_request:
types:
- closed

jobs:

attach-artifact-to-release:
uses: liquibase/build-logic/.github/workflows/[email protected]
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/build-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This workflow will build the extension against the latest Liquibase artifact
name: "Nightly build"

on:
schedule:
- cron: '0 7 * * 1-5'

jobs:
nightly-build:
uses: liquibase/build-logic/.github/workflows/[email protected]
with:
nightly: true
secrets: inherit
18 changes: 18 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CodeQL

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '16 14 * * 4'

jobs:
codeql:
uses: liquibase/build-logic/.github/workflows/[email protected]
secrets: inherit
with:
languages: '["java"]'
195 changes: 8 additions & 187 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,191 +1,12 @@
name: Release Extension (v2)
name: Create Release

on:
repository_dispatch:
types: [liquibase-release]
workflow_dispatch:
inputs:
liquibaseVersion:
description: 'Liquibase Version'
required: true
extensionVersion:
description: 'Extension Version (Defaults to Liquibase Version)'
required: false
push:
branches:
- main

jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
liquibaseVersion: ${{ steps.collect-data.outputs.liquibaseVersion }}
extensionVersion: ${{ steps.collect-data.outputs.extensionVersion }}
steps:
- name: Collect Data
id: collect-data
uses: actions/github-script@v4
with:
script: |
if (context.payload.client_payload) {
core.setOutput("liquibaseVersion", context.payload.client_payload.liquibaseVersion);
core.setOutput("extensionVersion", context.payload.client_payload.liquibaseVersion);
} else if (context.payload.inputs) {
core.setOutput("liquibaseVersion", context.payload.inputs.liquibaseVersion);
core.setOutput("extensionVersion", context.payload.inputs.extensionVersion || context.payload.inputs.liquibaseVersion);
} else {
core.setFailed('Unknown event type')
}

- run: |
echo "Saw Liquibase version ${{ steps.collect-data.outputs.liquibaseVersion }}"
echo "Saw Extension version ${{ steps.collect-data.outputs.extensionVersion }}"

build:
name: "Build and Test"
runs-on: ubuntu-latest
needs: setup
outputs:
releaseSha: ${{ steps.get-release-sha.outputs.releaseSha }}
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo

- name: Cache Built Code
uses: actions/cache@v2
with:
key: built-code-${{ github.run_id }}
path: ./**/target

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

- name: Configure git user
run: |
git config user.name "liquibot"
git config user.email "[email protected]"

- name: Download and install liquibase-core.jar
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "liquibase/liquibase"
version: "tags/v${{ needs.setup.outputs.liquibaseVersion }}"
file: "liquibase-core-${{ needs.setup.outputs.liquibaseVersion }}.jar"
target: "liquibase-core.jar"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install liquibase-core.jar
run: mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=liquibase-core.jar
- name: Update pom.xml with release versions and commit changes
run: |
mvn -B versions:set -DnewVersion=${{ needs.setup.outputs.extensionVersion }} -DallowSnapshots=false -DoldVersion="*"
mvn -B versions:use-dep-version -Dincludes=org.liquibase:liquibase-core -DdepVersion=${{ needs.setup.outputs.liquibaseVersion }} -DforceVersion=true

git add pom.xml
if git diff-index --cached --quiet HEAD --
then
echo "Nothing new to commit"
else
git commit -m "Version Bumped to ${{ needs.setup.outputs.extensionVersion }}"
fi
git tag -a -m "Version Bumped to ${{ needs.setup.outputs.extensionVersion }}" liquibase-db2i-${{ needs.setup.outputs.extensionVersion }}
git push "https://liquibot:[email protected]/$GITHUB_REPOSITORY.git" HEAD:${{ github.ref }} --follow-tags --tags

env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}

- name: Get release SHA
id: get-release-sha
run: echo ::set-output name=releaseSha::$(git rev-parse HEAD)


- name: Build and Unit Test
run: mvn -B clean test package

- name: Archive Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-reports-jdk
path: ./**/target/surefire-reports

- name: Save Artifacts
uses: actions/upload-artifact@v2
with:
name: liquibase-db2i
path: |
target/*.jar

integration-tests:
name: Java ${{ matrix.java }}
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
java: [8, 11, 17]
steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- name: Test With Maven
run: mvn clean verify --file pom.xml

draft-release:
needs: [ setup, build, integration-tests ]
name: Draft Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: liquibase-db2i

- name: Release
uses: softprops/action-gh-release@v1
with:
target_commitish: ${{ needs.build.outputs.releaseSha }}
name: v${{ needs.setup.outputs.extensionVersion }}
tag_name: liquibase-db2i-${{ needs.setup.outputs.extensionVersion }}
draft: true
body: Support for Liquibase ${{ needs.setup.outputs.liquibaseVersion }}.
files: liquibase-db2i-*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

bump-pom-to-snapshot:
name: Prepare POM for Development
runs-on: ubuntu-latest
needs: [ draft-release ]
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

- name: Configure git user
run: |
git config user.name "liquibot"
git config user.email "[email protected]"

- name: Prepare code for next version
run: |
git pull
mvn -B versions:set -DnextSnapshot=true
git add pom.xml
git commit -m "Version Bumped to Snapshot for Development"
git push "https://liquibot:[email protected]/$GITHUB_REPOSITORY.git" HEAD:${{ github.ref }} --follow-tags --tags
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
create-release:
uses: liquibase/build-logic/.github/workflows/[email protected]
secrets: inherit
19 changes: 19 additions & 0 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Pull Request Labels
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize, reopened]
jobs:
label:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Validate PR Labels
uses: mheap/github-action-required-labels@v5
with:
mode: minimum
count: 1
labels: "breakingChanges, newContributors, notableChanges, sdou, skipReleaseNotes, TypeBug, TypeEnhancement, TypeTest"
add_comment: true
message: "Label error: This PR is being prevented from merging because you have not added one of the labels: {{ provided }}. You'll need to add it before this PR can be merged."
Loading
Loading