Skip to content

Build and Publish Geoweaver App #4

Build and Publish Geoweaver App

Build and Publish Geoweaver App #4

Workflow file for this run

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 }}