Skip to content

Package build and deploy #104

Package build and deploy

Package build and deploy #104

Workflow file for this run

name: Package build and deploy
on:
workflow_dispatch:
inputs:
publish_maven:
description: "Publish to Maven"
required: true
type: boolean
release_made:
description: "I have used the scripts/set_version.sh script to set the new version."
required: true
type: boolean
publish_only_maven:
description: "(DEV) Publish only to Maven"
required: true
type: boolean
concurrency:
group: ${{ github.ref }}-build
cancel-in-progress: true
jobs:
check_release:
name: Check input parameters
if: ${{ !inputs.publish_only_maven && !inputs.release_made }}
runs-on: ubuntu-latest
steps:
- run: echo "Release check wasn't checked"
build:
name: Building project
if: ${{ inputs.publish_only_maven || inputs.release_made }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version_get.outputs.version }}
steps:
- uses: actions/checkout@v3
- id: version_get
run: echo "version=$(scripts/get_version.sh)" >> $GITHUB_OUTPUT
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: 17
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache-dependency-path: qendpoint-frontend/package-lock.json
- name: Install frontend dependencies
run: npm ci --legacy-peer-deps
working-directory: qendpoint-frontend
- name: Validate frontend format
run: npm run validate
working-directory: qendpoint-frontend
- name: Compiling frontend
run: npm run build --if-present
working-directory: qendpoint-frontend
- name: Put frontend in backend
run: |
mkdir -p qendpoint-backend/src/main/resources/static/
cp -r qendpoint-frontend/build/* qendpoint-backend/src/main/resources/static/
- name: Compile qendpoint
run: mvn install
- name: move endpoint
run: mv qendpoint-backend/target/qendpoint-*-exec.jar qendpoint.jar
- name: Deploy jar
uses: actions/upload-artifact@v3
with:
name: "qendpoint.jar"
path: "qendpoint.jar"
- name: move cli
run: mv qendpoint-cli/target/qendpoint-cli-*-distribution.zip qendpoint-cli.zip
- name: Deploy CLI zip
uses: actions/upload-artifact@v3
with:
name: "qendpoint-cli.zip"
path: "qendpoint-cli.zip"
publish:
name: Publish to Maven Central
needs: build
runs-on: ubuntu-latest
if: ${{ inputs.publish_only_maven || inputs.publish_maven }}
permissions:
contents: read
packages: write
steps:
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: 17
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- uses: actions/checkout@v3
- name: maven-settings-action
uses: s4u/maven-settings-action@v2.5.0
with:
servers: '[{"id": "sonatype-nexus-snapshots", "username": "${{ secrets.SONATYPE_NEXUS_USERNAME }}", "password": "${{ secrets.SONATYPE_NEXUS_PASSWORD }}"},{"id": "sonatype-nexus-staging", "username": "${{ secrets.SONATYPE_NEXUS_USERNAME }}", "password": "${{ secrets.SONATYPE_NEXUS_PASSWORD }}"}]'
- name: Publish to the Maven Central Repository
run: mvn --batch-mode clean deploy -P release -DskipTests
osx:
name: Build OSX version
needs: build
runs-on: macos-latest
if: ${{ !inputs.publish_only_maven }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: 17
- name: Download qendpoint jar
uses: actions/download-artifact@v3
with:
name: "qendpoint.jar"
- name: Create Icon
run: scripts/create_osx_icon.sh docs/images/logo_fill_icon.png docs/images/mac_icons.icns
- name: Package jar as dmg installer
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MAOS_CERTIFICATE_PWD }}
MACOS_KEYCHAIN_PWD: ${{ secrets.MACOS_KEYCHAIN_PWD }}
MACOS_DEV_ID: ${{ secrets.MACOS_DEVID }}
MACOS_TEAMID: ${{ secrets.MACOS_TEAMID }}
AC_PASSWORD: ${{ secrets.NOTARIZATION_PASSWORD }}
NOTARIZATION_USERNAME_NEW: ${{ secrets.NOTARIZATION_USERNAME_NEW }}
NOTARIZATION_TEAM_NEW: ${{ secrets.NOTARIZATION_TEAM_NEW }}
NOTARIZATION_PASSWORD_NEW: ${{ secrets.NOTARIZATION_PASSWORD_NEW }}
run: scripts/build_package_osx.sh qendpoint.jar
- name: Upload dmg
uses: actions/upload-artifact@v3
with:
name: "qendpoint.dmg"
path: "qendpoint.dmg"
windows:
name: Build WINDOWS version
needs: build
runs-on: windows-latest
if: ${{ !inputs.publish_only_maven }}
steps:
- uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: 17
- name: Download endpoint jar
uses: actions/download-artifact@v3
with:
name: "qendpoint.jar"
- name: Package jar as msi installer
run: |
scripts/build_package.ps1 scripts/jpackage_windows.cfg qendpoint.jar
mv scripts/build/distributions/*.msi qendpoint.msi
- name: Upload installer
uses: actions/upload-artifact@v3
with:
name: "qendpoint.msi"
path: "qendpoint.msi"
linux:
name: Build LINUX version
needs: build
runs-on: ubuntu-latest
if: ${{ !inputs.publish_only_maven }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: 17
- name: Download endpoint jar
uses: actions/download-artifact@v3
with:
name: "qendpoint.jar"
- name: Package jar as deb installer
run: |
scripts/build_package.sh scripts/jpackage_linux.cfg qendpoint.jar
mv scripts/build/distributions/*.deb qendpoint.deb
- name: Upload installer
uses: actions/upload-artifact@v3
with:
name: "qendpoint.deb"
path: "qendpoint.deb"
push_to_docker_hub:
name: Push to Docker Hub base image
needs:
- build
environment:
name: qendpoint docker image
url: https://hub.docker.com/r/qacompany/qendpoint/tags
runs-on: ubuntu-latest
if: ${{ !inputs.publish_only_maven }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download qendpoint jar
uses: actions/download-artifact@v3
with:
name: "qendpoint.jar"
- name: Move endpoint
run: mv qendpoint.jar scripts
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: qacompany/qendpoint
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
file: scripts/Dockerfile
context: scripts
push: true
tags: "qacompany/qendpoint:latest,qacompany/qendpoint:${{ needs.build.outputs.version }}"
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}
push_to_docker_hub_wikidata:
name: Push to Docker Hub wikidata image
environment:
name: qendpoint-wikidata docker image
url: https://hub.docker.com/r/qacompany/qendpoint-wikidata/tags
needs:
- build
- push_to_docker_hub
runs-on: ubuntu-latest
if: ${{ !inputs.publish_only_maven }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: qacompany/qendpoint
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
file: scripts/Dockerfile-wikidata
context: scripts
push: true
tags: "qacompany/qendpoint-wikidata:latest,qacompany/qendpoint-wikidata:${{ needs.build.outputs.version }}"
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}
create_release:
name: Create Github release
environment:
name: qendpoint release
url: "https://github.com/the-qa-company/qEndpoint/releases/tag/v${{ needs.build.outputs.version }}"
needs:
- build
- linux
- windows
- osx
- push_to_docker_hub_wikidata
runs-on: ubuntu-latest
if: ${{ !inputs.publish_only_maven }}
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Extract artifacts
run: |
mkdir -p deploy_file
mv qendpoint.*/* deploy_file
mv qendpoint-cli.*/* deploy_file
- name: Compute hashes
run: |
chmod u+x scripts/hashfiles.sh
echo " " >> release/SUFFIX.md
echo " " >> release/SUFFIX.md
echo '**SHA256**' >> release/SUFFIX.md
echo '' >> release/SUFFIX.md
echo '```' >> release/SUFFIX.md
scripts/hashfiles.sh deploy_file >> release/SUFFIX.md
echo '```' >> release/SUFFIX.md
- name: Create release body
run: |
chmod u+x scripts/build_release_input.sh
scripts/build_release_input.sh
- name: Create release with artifacts
uses: ncipollo/release-action@v1
with:
commit: ${{ github.sha }}
tag: "v${{ needs.build.outputs.version }}"
artifacts: "deploy_file/*"
name: "Release ${{ needs.build.outputs.version }}"
bodyFile: "release/RELEASE_OUTPUT.md"
token: ${{ secrets.GITHUB_TOKEN }}