change setup to setup-and-build #120
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: | |
push: | |
branches: | |
- feat/update-actions | |
jobs: | |
setup-and-build: | |
runs-on: ubuntu-latest | |
outputs: | |
release_version: ${{ steps.grep_release_version.outputs.release_version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install gitpython | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- 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 | |
- name: Run Python build script | |
run: | | |
cd misc | |
python3 build.py | |
- 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 | |
- 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: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- 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: | |
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 | |
- 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/ | |
- 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 | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Download gigwa directory | |
uses: actions/download-artifact@v3 | |
with: | |
name: gigwa | |
path: target/gigwa/ | |
- 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 |