Gigwa Build #126
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gigwa Build | |
on: | |
workflow_dispatch | |
jobs: | |
setup-and-build: | |
runs-on: ubuntu-latest | |
outputs: | |
# Output the release version to be used in the following steps | |
release_version: ${{ steps.grep_release_version.outputs.release_version }} | |
steps: | |
- uses: actions/checkout@v4 | |
# Set up Python for the build script | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
# Install Python dependencies for the build script | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install gitpython | |
# Set up Java for the maven build | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
# Get the release version from the pom.xml file | |
- name: Grep release version | |
id: grep_release_version | |
run: | | |
echo "release_version=$(grep -m 1 project\\\.version pom.xml | sed -n 's/.*<project\.version>\(.*\)<\/project\.version>.*/\1/p')" >> $GITHUB_OUTPUT | |
# Run the maven build script which will build the project and create the Webapp zip | |
- name: Run Python build script | |
run: | | |
cd misc | |
python3 build.py | |
# Upload the Webapp zip as artifact for upload-release-assets | |
- name: Upload Webapp zip | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Gigwa_V${{ steps.grep_release_version.outputs.release_version }}_Webapp.zip | |
path: target/Gigwa_V${{ steps.grep_release_version.outputs.release_version }}_Webapp.zip | |
# Upload the Gigwa directory as artifact for the Dockerfile | |
- name: Upload Gigwa directory | |
uses: actions/upload-artifact@v3 | |
with: | |
name: gigwa | |
path: target/gigwa/ | |
create-release: | |
needs: setup-and-build | |
runs-on: ubuntu-latest | |
outputs: | |
# Output the upload URL to be used in the following steps | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
# Create a release with the good version and add a description | |
- name: Create Release | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "${{ needs.setup-and-build.outputs.release_version }}" | |
release_name: "${{ needs.setup-and-build.outputs.release_version }}" | |
body: | | |
For initial setups not using Docker, download the bundle creation script corresponding to your OS, place it in the desired installation location, and launch it! | |
draft: false | |
prerelease: false | |
upload-release-assets: | |
needs: [setup-and-build, create-release] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# Define the assets to be uploaded with their path, name, content type, and add a flag "download" to download the asset before uploading it | |
asset: | |
- { path: "target/Gigwa_V${{ needs.setup-and-build.outputs.release_version }}_Webapp.zip", name: "Gigwa_V${{ needs.setup-and-build.outputs.release_version }}_Webapp.zip", content_type: "application/zip", downloaded: true } | |
- { path: "misc/macos_bundle.command", name: "Gigwa_V${{ needs.setup-and-build.outputs.release_version }}_bundle_creation_osx.command", content_type: "application/x-sh" } | |
- { path: "misc/linux_bundle.sh", name: "Gigwa_V${{ needs.setup-and-build.outputs.release_version }}_bundle_creation_ubuntu.sh", content_type: "application/x-sh" } | |
- { path: "misc/win_bundle.ps1", name: "Gigwa_V${{ needs.setup-and-build.outputs.release_version }}_bundle_creation_windows.ps1", content_type: "application/powershell" } | |
- { path: "docker-compose.yml", name: "Gigwa_V${{ needs.setup-and-build.outputs.release_version }}_docker-compose.yml", content_type: "application/yml" } | |
steps: | |
- uses: actions/checkout@v4 | |
# Download the asset if the flag "download" is set to true | |
- name: Download Webapp zip | |
if: matrix.asset.downloaded == true | |
uses: actions/download-artifact@v3 | |
with: | |
name: Gigwa_V${{ needs.setup-and-build.outputs.release_version }}_Webapp.zip | |
path: target/ | |
# Upload the asset to the release | |
- name: Upload Release Asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: ${{ matrix.asset.path }} | |
asset_name: ${{ matrix.asset.name }} | |
asset_content_type: ${{ matrix.asset.content_type }} | |
build-push-docker: | |
needs: [ setup-and-build, create-release ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Set up Docker Buildx for multi-platform builds | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
# Login to Docker Hub | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Download the Gigwa directory artifact for the Dockerfile | |
- name: Download gigwa directory | |
uses: actions/download-artifact@v3 | |
with: | |
name: gigwa | |
path: target/gigwa/ | |
# Build and push the Docker image | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/gigwa:${{ needs.setup-and-build.outputs.release_version }} | |
${{ secrets.DOCKERHUB_USERNAME }}/gigwa:latest |