Skip to content

Commit

Permalink
Merge pull request #42 from liquibase/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
dmitry-shanko authored Jun 26, 2023
2 parents a2efb48 + d9f5e01 commit adf5cb2
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 156 deletions.
91 changes: 0 additions & 91 deletions .github/workflows/attach-artifact-release.yml

This file was deleted.

162 changes: 162 additions & 0 deletions .github/workflows/create-release-with-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Create Draft Release with Artifacts

on:
workflow_dispatch:
secrets:
BOT_TOKEN:
description: 'BOT_TOKEN from the caller workflow'
required: true
GPG_SECRET:
description: 'GPG_SECRET from the caller workflow'
required: true
GPG_PASSPHRASE:
description: 'GPG_PASSPHRASE from the caller workflow'
required: true

jobs:
build:
name: Build Maven Artifacts
runs-on: ubuntu-latest
outputs:
artifactId: ${{ steps.collect-data.outputs.artifactId }}
artifactVersion: ${{ steps.collect-data.outputs.artifactVersion }}
releaseSha: ${{ steps.collect-data.outputs.releaseSha }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'temurin'
cache: 'maven'

- name: Build with Maven
run: mvn package --file liquibase-couchbase/pom.xml -DskipTests

- name: Get Artifact ID
id: get-artifact-id
run: echo "artifact_id=$(mvn --file liquibase-couchbase/pom.xml help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV

- name: Get Artifact Version
id: get-artifact-version
run: echo "artifact_version=$(mvn --file liquibase-couchbase/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV

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

- name: Collect Data
id: collect-data
uses: actions/github-script@v4
with:
script: |
core.setOutput("artifactId", '${{ env.artifact_id }}');
core.setOutput("artifactVersion", '${{ env.artifact_version }}');
core.setOutput("releaseSha", '${{ env.releaseSha }}');
- name: Echo Build Info
id: echo-version
run: |
echo "Get Extension artifacts ${{ env.artifact_id }}-${{ env.artifact_version }}"
- name: Publish Artifacts
uses: actions/upload-artifact@v2
with:
name: liquibase-couchbase
path: liquibase-couchbase/target/*

release:
name: Create Release with Artifacts
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- name: Get Reusable Script Files
run: |
curl -o $PWD/.github/get_draft_release.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.1/.github/get_draft_release.sh
curl -o $PWD/.github/sign_artifact.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.1/.github/sign_artifact.sh
curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.1/.github/upload_asset.sh
chmod +x $PWD/.github/get_draft_release.sh
chmod +x $PWD/.github/sign_artifact.sh
chmod +x $PWD/.github/upload_asset.sh
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: liquibase-couchbase

- name: Prepare Artifact Name
id: artifact-name
run: echo "artifactName=${{ needs.build.outputs.artifactId }}-${{ needs.build.outputs.artifactVersion }}" >> $GITHUB_ENV

- name: Create Tag Name
id: tag-name
run: echo "tagName=${{ needs.build.outputs.artifactVersion }}" >> $GITHUB_ENV

- name: Echo Info
id: echo-version
run: |
echo "Artifacts: ${{ env.artifactName }}"
echo "Tag Name: ${{ env.tagName }}"
- name: Create Draft Release
uses: softprops/action-gh-release@v1
with:
target_commitish: ${{ needs.build.outputs.releaseSha }}
name: v${{ needs.build.outputs.artifactVersion }}
tag_name: ${{ env.tagName }}
draft: true
body: Liquibase Couchbase extension v${{ needs.build.outputs.artifactVersion }}
files: liquibase-couchbase
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}

- name: Delete Outdated Files from Draft Release
id: delete-outdated-release-asset
uses: mknejp/delete-release-assets@v1
with:
token: ${{ secrets.BOT_TOKEN }}
tag: ${{ env.tagName }}
fail-if-no-assets: false
fail-if-no-release: false
assets: "${{ needs.build.outputs.artifactId }}-*"

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_SECRET }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Generate MD5 checksum
run: |
md5sum ./${{ env.artifactName }}.jar > ./${{ env.artifactName }}.jar.md5
md5sum ./${{ env.artifactName }}.pom > ./${{ env.artifactName }}.pom.md5
md5sum ./${{ env.artifactName }}-javadoc.jar > ./${{ env.artifactName }}-javadoc.jar.md5
md5sum ./${{ env.artifactName }}-sources.jar > ./${{ env.artifactName }}-sources.jar.md5
- name: Generate SHA-1 checksum
run: |
sha1sum ./${{ env.artifactName }}.jar > ./${{ env.artifactName }}.jar.sha1
sha1sum ./${{ env.artifactName }}.pom > ./${{ env.artifactName }}.pom.sha1
sha1sum ./${{ env.artifactName }}-javadoc.jar > ./${{ env.artifactName }}-javadoc.jar.sha1
sha1sum ./${{ env.artifactName }}-sources.jar > ./${{ env.artifactName }}-sources.jar.sha1
- name: Sign Files for Draft Release
run: |
gpg -K
passphrase="${{ secrets.GPG_PASSPHRASE }}"
export GPG_TTY=$(tty)
echo "$passphrase" | gpg --batch --pinentry-mode loopback --passphrase-fd 0 --sign --armor --detach-sign ./${{ env.artifactName }}.jar
echo "$passphrase" | gpg --batch --pinentry-mode loopback --passphrase-fd 0 --sign --armor --detach-sign ./${{ env.artifactName }}.pom
echo "$passphrase" | gpg --batch --pinentry-mode loopback --passphrase-fd 0 --sign --armor --detach-sign ./${{ env.artifactName }}-javadoc.jar
echo "$passphrase" | gpg --batch --pinentry-mode loopback --passphrase-fd 0 --sign --armor --detach-sign ./${{ env.artifactName }}-sources.jar
- name: Attach Files to Draft Release
id: upload-release-asset
run: ./.github/upload_asset.sh ${{ needs.build.outputs.artifactVersion }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
ASSET_NAME_PREFIX: "${{ needs.build.outputs.artifactId }}-"
ASSET_DIR: .
15 changes: 0 additions & 15 deletions .github/workflows/create-release.yml

This file was deleted.

102 changes: 61 additions & 41 deletions .github/workflows/release-published.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ name: Release Extension to Sonatype

on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Release Version'
required: true
release:
types: [published]
types: [ published ]
secrets:
SONATYPE_USERNAME:
description: 'SONATYPE_USERNAME from the caller workflow'
Expand All @@ -16,43 +20,59 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Get Artifact ID
id: get-artifact-id
run: echo "artifact_id=$(mvn --file liquibase-couchbase/pom.xml help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV

- name: Download Release Artifacts
uses: robinraju/[email protected]
with:
tag: "${{ github.event.release.tag_name }}"
filename: "${{ env.artifact_id }}-*"
out-file-path: "."

- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: sonatype-nexus-staging
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

# - name: Publish to Maven Central
# env:
# MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
# MAVEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN }}
# run: |
# version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
# mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
# -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
# -DrepositoryId=sonatype-nexus-staging \
# -DpomFile=${{ env.artifact_id }}-${version}.pom \
# -DgeneratePom=false \
# -Dfile=${{ env.artifact_id }}-${version}.jar \
# -Dsources=${{ env.artifact_id }}-${version}-sources.jar \
# -Djavadoc=${{ env.artifact_id }}-${version}-javadoc.jar \
# -Dfiles=${{ env.artifact_id }}-${version}.jar.asc,${{ env.artifact_id }}-${version}-sources.jar.asc,${{ env.artifact_id }}-${version}-javadoc.jar.asc,${{ env.artifact_id }}-${version}.pom.asc \
# -Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
# -Dclassifiers=,sources,javadoc,
- uses: actions/checkout@v3

- name: Collect Env Data
id: get-env-data
run: |
echo "artifact_id=$(mvn --file liquibase-couchbase/pom.xml help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV
echo "artifact_version=${{ inputs.releaseVersion }}" >> $GITHUB_ENV
echo "tag_name=${{ inputs.releaseVersion }}" >> $GITHUB_ENV
echo "artifact_name=${{ env.artifact_id }}-${{ env.artifact_version }}" >> $GITHUB_ENV
- name: Collect Artifact Name
id: get-artifact-name
run: echo "artifact_name=${{ env.artifact_id }}-${{ env.artifact_version }}" >> $GITHUB_ENV

- name: Echo Build Info
id: echo-info
run: |
echo "Artifact Id: ${{ env.artifact_id }}"
echo "Artifact Version: ${{ env.artifact_version }}"
echo "Artifact Full Name: ${{ env.artifact_name }}"
echo "Tag Name: ${{ env.tag_name }}"
- name: Download Release Artifacts
uses: robinraju/[email protected]
with:
tag: "${{ env.tag_name }}"
filename: "${{ env.artifact_id }}-*"
out-file-path: "."

- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: sonatype-nexus-staging
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- name: Publish to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN }}
run: |
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=${{ env.artifact_name }}.pom \
-DgeneratePom=false \
-Dbuild.version=${{ env.artifact_version }} \
-Dfile=${{ env.artifact_name }}.jar \
-Dsources=${{ env.artifact_name }}-sources.jar \
-Djavadoc=${{ env.artifact_name }}-javadoc.jar \
-Dfiles=${{ env.artifact_name }}.jar.asc,${{ env.artifact_name }}-sources.jar.asc,${{ env.artifact_name }}-javadoc.jar.asc,${{ env.artifact_name }}.pom.asc \
-Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
-Dclassifiers=,sources,javadoc,
2 changes: 1 addition & 1 deletion cli-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>cli-test</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>${build.version}</version>
<packaging>jar</packaging>

<properties>
Expand Down
Loading

0 comments on commit adf5cb2

Please sign in to comment.