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

DAT-15646




 Reusable Debian Package Creation Workflow Migration #51

Merged
merged 18 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6b12144
feat(deb-packaging.yml): add new workflow for creating and uploading …
Aug 10, 2023
e9f124d
chore(pom.xml): remove liquibase-pro repository from the project conf…
Aug 10, 2023
c49bee2
fix(deb-packaging.yml): update mvn package command to use deb-pom.xml…
Aug 10, 2023
88ace45
feat(package-deb.yml): add workflow for creating and uploading deb pa…
Aug 11, 2023
a9dedae
chore(package-deb-pom.xml): add pom.xml for deb packaging
Aug 11, 2023
5ba9b8e
chore(package-deb-pom.xml): remove unused profile for remote reposito…
Aug 11, 2023
0564f96
chore(package-deb.yml): update workflow to include required inputs an…
Aug 11, 2023
338230d
chore(package-deb.yml): add step to download reusable pom.xml file fo…
Aug 11, 2023
ac539f0
chore(package-deb-pom.xml): remove unnecessary dependencies and plugi…
Aug 11, 2023
8f73b44
chore(package-deb-pom.xml): reformat XML code for better readability …
Aug 11, 2023
fef9540
fix(package-deb.yml): add offline mode flag (-o) to the mvn package c…
Aug 11, 2023
114f675
chore(package-deb.yml): remove unnecessary -o flag from mvn package c…
Aug 11, 2023
cdd0048
fix(package-deb.yml): remove unnecessary maven.repo.local argument fr…
Aug 11, 2023
d3cff2b
chore(package-deb.yml): add verbose flag to mvn package command for d…
Aug 11, 2023
e1a83b8
feat(package-deb): add support for packaging the application as a Deb…
Aug 11, 2023
b266e54
chore(package-deb.yml): update step name to reflect the purpose of ge…
Aug 11, 2023
37ffcd1
fix(package-deb.yml): remove 'clean' phase from the Maven build comma…
Aug 11, 2023
32f67a2
chore(package-deb.yml): add comments to explain the purpose of certai…
Aug 11, 2023
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
77 changes: 77 additions & 0 deletions .github/package-deb-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${revision}</version>
<description>Universal pom for deb packaging</description>

<properties>
<maven.antrun.version>3.1.0</maven.antrun.version>
<org.vafer.jdeb.version>1.10</org.vafer.jdeb.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven.antrun.version}</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<configuration>
<target>
<untar src="${project.build.directory}/${project.artifactId}-${project.version}.tar.gz" compression="gzip" dest="${project.build.directory}/dist-unpacked" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.vafer</groupId>
<artifactId>jdeb</artifactId>
<version>${org.vafer.jdeb.version}</version>
<executions>
<execution>
<id>create-deb</id>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
</execution>
</executions>
<configuration>
<deb>${project.build.directory}/${project.artifactId}-${project.version}.deb</deb>
<controlDir>${project.basedir}/src/${project.artifactId}/deb/control</controlDir>
<dataSet>
<data>
<src>${project.build.directory}/dist-unpacked</src>
<type>directory</type>
<mapper>
<type>perm</type>
<prefix>/opt/liquibase</prefix>
<filemode>755</filemode>
</mapper>
</data>
<data>
<src>${project.basedir}/src/${project.artifactId}/main/archive/${project.artifactId}-env.sh</src>
<type>file</type>
<mapper>
<type>perm</type>
<prefix>/etc/profile.d/</prefix>
<filemode>755</filemode>
</mapper>
</data>
</dataSet>
</configuration>
</plugin>
</plugins>
</build>
</project>
102 changes: 102 additions & 0 deletions .github/workflows/package-deb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: DEB packaging
on:
workflow_call:
inputs:
groupId:
description: 'Value from the groupId field in pom.xml. i.e. org.liquibase'
required: true
type: string
artifactId:
description: 'Value from the artifactId field in pom.xml. i.e. liquibase'
required: true
type: string
version:
description: 'Value from the version field in pom.xml. i.e 4.23.0'
type: string
secrets:
AWS_PROD_ACCESS_KEY_ID:
description: 'AWS_PROD_ACCESS_KEY_ID from the caller workflow'
required: true
AWS_PROD_SECRET_ACCESS_KEY:
description: 'AWS_PROD_SECRET_ACCESS_KEY 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
GPG_SECRET_KEY_ID:
description: 'GPG_SECRET_KEY_ID from the caller workflow'
required: true


env:
MAVEN_VERSION: '3.9.2'

jobs:

upload_deb:
name: Upload ${{ inputs.artifactId }} deb package
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'

- name: Get Reusable Maven Files
run: |
# Under the src folder is where specific packages files live. The GitHub action inputs will modify the universal package-deb-pom.xml to tell the process which assets to use during the packaging step
mkdir -p $PWD/.github/src/${{ inputs.artifactId }}/deb/control
mkdir -p $PWD/.github/src/${{ inputs.artifactId }}/main/archive
curl -o $PWD/.github/src/${{ inputs.artifactId }}/deb/control/control https://raw.githubusercontent.com/liquibase/build-logic/v0.3.7/src/${{ inputs.artifactId }}/deb/control/control
curl -o $PWD/.github/src/${{ inputs.artifactId }}/deb/control/postinst https://raw.githubusercontent.com/liquibase/build-logic/v0.3.7/src/${{ inputs.artifactId }}/deb/control/postinst
curl -o $PWD/.github/src/${{ inputs.artifactId }}/main/archive/${{ inputs.artifactId }}-env.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.7/src/${{ inputs.artifactId }}/main/archive/${{ inputs.artifactId }}-env.sh
curl -o $PWD/.github/package-deb-pom.xml https://raw.githubusercontent.com/liquibase/build-logic/v0.3.7/.github/package-deb-pom.xml

- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: ${{ env.MAVEN_VERSION }}

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Download ${{ inputs.artifactId }} Release
run: |
mkdir -p $PWD/.github/target
# Creating deb packages needs to get release assets from somewhere so be sure to follow this pattern in the artifact repo: https://github.com/liquibase/ARTIFACT_ID/releases/download/vVERSION/ARTIFACT_ID-VERSION.tar.gz
wget -q -O $PWD/.github/target/${{ inputs.artifactId }}-${{ inputs.version }}.tar.gz https://github.com/liquibase/${{ inputs.artifactId }}/releases/download/v${{ inputs.version }}/${{ inputs.artifactId }}-${{ inputs.version }}.tar.gz

- name: Build ${{ inputs.artifactId }} deb package
run: |
mvn package -f $PWD/.github/package-deb-pom.xml -DgroupId=${{ inputs.groupId }} -DartifactId=${{ inputs.artifactId }} -Drevision=${{ inputs.version }} -DskipTests

- name: Install deb-s3 gem
run: gem install deb-s3

- name: Upload ${{ inputs.artifactId }} deb package
run: |
sudo apt install pinentry-tty
echo "2" | sudo update-alternatives --config pinentry
echo "${{ secrets.GPG_SECRET }}" | gpg --batch --import --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}"
export GPG_TTY=$(tty)
echo '${{ secrets.GPG_PASSPHRASE }}' > pass.txt
deb-s3 upload --preserve-versions --sign "${{ secrets.GPG_SECRET_KEY_ID }}" --gpg-options "\-\-pinentry-mode loopback \-\-batch \-\-passphrase\-file pass.txt \-\-yes \-\-quiet" --bucket repo.liquibase.com $PWD/.github/target/${{ inputs.artifactId }}-${{ inputs.version }}.deb



7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ jobs:

If inputs are not provided, `'[8, 11, 17, 18]'` and `'["ubuntu-latest", "windows-latest"]'` will be used as default values

`package-deb.yml` is triggered by a workflow call event and runs some Maven goals needed to create and distribute `deb` packages. It has several inputs:

- **groupId**: Value from the `groupId` field in the pom file. i.e. `org.liquibase`
- **artifactId**: Value from the `artifactId` field in the pom file. i.e. `liquibase`
- **version**: Value from the `version` field in the pom file. i.e `4.23.1`

## Example Build/Test/Release Extension Workflow

```mermaid
Expand All @@ -66,6 +72,7 @@ Please review the below table of reusable workflows and their descriptions:
| `extension-release-published.yml` | Publishes a release to Maven Central |
| `extension-update-version.yml` | Updates release and development `pom.xml` versions |
| `os-extension-test.yml` | Unit tests across build matrix on previously built artifact |
| `package-deb.yml` | Creates and uploads deb packages |
| `pro-extension-test.yml` | Same as OS job, but with additional Pro-only vars such as License Key |
| `sonar-pull-request.yml` | Code Coverage Scan for PRs. Requires branch name parameter |
| `sonar-push.yml` | Same as PR job, but for pushes to main. Does not require branch name parameter |
Expand Down
9 changes: 9 additions & 0 deletions src/liquibase/deb/control/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: liquibase
Version: [[version]]
Section: misc
Priority: optional
Architecture: all
Depends:
Maintainer: Nathan Voxland <nathan.voxland@liquibase.org>
Description: Liquibase Debian Installer
Distribution: development
6 changes: 6 additions & 0 deletions src/liquibase/deb/control/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# Needed once the installation is complete. No need to open a new terminal
export LIQUIBASE_HOME=/opt/liquibase
export PATH=$PATH:$LIQUIBASE_HOME
exec $SHELL
6 changes: 6 additions & 0 deletions src/liquibase/main/archive/liquibase-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# Needed when restarting the terminal
export LIQUIBASE_HOME=/opt/liquibase
export PATH=$PATH:$LIQUIBASE_HOME
exec $SHELL