Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ZihengSun/Geoweaver
Browse files Browse the repository at this point in the history
  • Loading branch information
ZihengSun committed Oct 23, 2023
2 parents 8ecd9c8 + 90805ed commit f607cb6
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Build and Publish Geoweaver App

on:
release:
types:
- published
tags:
- '*'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Build with Maven
run: mvn clean install -DskipTests

- name: Install XML parsing tools
run: sudo apt-get update && sudo apt-get install -y libxml2-utils

- name: Extract version from pom.xml
run: |
VERSION=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" $GITHUB_WORKSPACE/pom.xml)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Append version to DEBIAN/control
run: |
echo "Version: ${{ env.VERSION }}" >> $GITHUB_WORKSPACE/linux-deployment/DEBIAN/control
- name: Set execute permissions for postinst script
run: chmod 755 $GITHUB_WORKSPACE/linux-deployment/DEBIAN/postinst

- name: Copy geoweaver.jar to linux-deployment directory
run: cp $GITHUB_WORKSPACE/target/geoweaver.jar $GITHUB_WORKSPACE/linux-deployment/usr/local/bin/

- name: Make geoweaver.sh executable
run: chmod +x $GITHUB_WORKSPACE/linux-deployment/usr/local/bin/geoweaver.sh

- name: Build deb package
run: |
cd $GITHUB_WORKSPACE/linux-deployment
dpkg-deb --build . geoweaver.deb
- name: Upload Geoweaver Artifacts
uses: actions/upload-artifact@v2
with:
name: geoweaver-artifacts
path: |
target/*.jar
pom.xml
linux-deployment/*.deb
release:
needs: build
runs-on: ubuntu-latest

steps:
- name: Install XML parsing tools
run: sudo apt install libxml2-utils

- name: Install jq
run: sudo apt-get install jq

- name: Download Geoweaver Artifacts
uses: actions/download-artifact@v2
with:
name: geoweaver-artifacts

- name: Get ID and upload URL of the latest release
run: |
RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.PAT }}" "https://api.github.com/repos/${{ github.repository }}/releases/latest")
UPLOAD_URL=$(echo "$RESPONSE" | jq -r .upload_url)
RELEASE_ID=$(echo "$RESPONSE" | jq -r .id)
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV
- name: Set release title to version
run: |
curl -X PATCH \
-H "Authorization: token ${{ secrets.PAT }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }} \
-d '{"name": "${{ env.VERSION }}"}'
- name: Upload JAR Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: /home/runner/work/geoweaver-deployment-test/geoweaver-deployment-test/target/geoweaver.jar
asset_name: geoweaver.jar
asset_content_type: application/java-archive
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Upload DEB Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: /home/runner/work/geoweaver-deployment-test/geoweaver-deployment-test/linux-deployment/geoweaver.deb
asset_name: geoweaver.deb
asset_content_type: application/vnd.debian.binary-package
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
5 changes: 5 additions & 0 deletions linux-deployment/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: geoweaver
Architecture: all
Maintainer: Geoweaver team <[email protected]>
Description: Geoweaver
Depends: openjdk-11-jre
4 changes: 4 additions & 0 deletions linux-deployment/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e
update-desktop-database

Binary file added linux-deployment/usr/local/bin/geoweaver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions linux-deployment/usr/local/bin/geoweaver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
java -jar /usr/local/bin/geoweaver.jar &
SERVER_PID=$!

# Wait for the server to start (adjust the time as needed)
sleep 7

# Open the URL in the default web browser
xdg-open http://localhost:8070/Geoweaver

# Wait for the server to complete before exiting
wait $SERVER_PID
9 changes: 9 additions & 0 deletions linux-deployment/usr/share/applications/geoweaver.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Geoweaver
Comment=Geoweaver Application
Exec=/usr/local/bin/geoweaver.sh
Icon=/usr/local/bin/geoweaver.png
Terminal=false
Type=Application
Categories=Utility;

0 comments on commit f607cb6

Please sign in to comment.