Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Add GitHub action (#2)
Browse files Browse the repository at this point in the history
Implemented github action which:

- compiles

- tests

- packages

- releases and deploys to assets if tag is created
  • Loading branch information
okopanja committed Apr 5, 2022
1 parent d1a4327 commit 7b3edfc
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 35 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build_zip_bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: TheWay -> comile, test, package, create realase(on tag)
on: push
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Prepare versions for EXE file
uses: actions/github-script@v6
id: set_version
with:
script: |
const tag = context.ref.substring(10)
const no_v = tag.replace(/[^\d.-]/g, '')
const dash_index = no_v.lastIndexOf('-')
const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v
var file_version = no_dash
components = no_dash.split('.')
console.log(no_dash)
for (let i = 0; i < (4 - components.length); i++) {
file_version = file_version + '.0'
}
console.log(file_version)
core.setOutput('tag', tag)
core.setOutput('tag-no-v', no_v)
core.setOutput('tag-no-dash', no_dash)
core.setOutput('file-version', file_version)
if: startsWith(github.ref, 'refs/tags/')
- name: Maven -> set version based on tag
run: mvn --batch-mode versions:set -DnewVersion="${{ steps.set_version.outputs.tag-no-dash }}"
if: startsWith(github.ref, 'refs/tags/')
- name: Maven -> compile and test
run: mvn --batch-mode compile test
- name: Maven -> package
run: mvn --batch-mode package -Dfile_version="${{ steps.set_version.outputs.file-version }}" -Dtag_version="${{ steps.set_version.outputs.tag }}" -Drelease_url="${{ github.server_url }}/${{github.repository}}/releases/tag/${{ github.ref_name }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
- name: Create release and upload asset
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: target/dcstheway-${{ steps.set_version.outputs.tag-no-dash }}.zip
repo-token: ${{ secrets.GITHUB_TOKEN }}
67 changes: 32 additions & 35 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>DCSTheWay</artifactId>
<version>1.0.0.0</version>
<artifactId>dcstheway</artifactId>
<version>0.0.0</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<!-- the following values will be overriden by of github actions based on tag -->
<tag_version>0.0.0</tag_version>
<file_version>0.0.0.0</file_version>
<release_url>https://github.com/aronCiucu/DCSTheWay/releases</release_url>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -40,15 +44,7 @@
</resource>
</resources>
<plugins>
<!-- For bundling of exe we need to get rid of -SNAPSHOT from version -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<configuration>
<removeSnapshot>true</removeSnapshot>
</configuration>
</plugin>
<!-- create jar with dependencies bundled inside-->
<!-- create jar with dependencies bundled -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
Expand All @@ -72,7 +68,7 @@
</execution>
</executions>
</plugin>
<!-- create exe from the -->
<!-- create exe from the bundled jar -->
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
Expand All @@ -98,12 +94,12 @@
</opts>
</jre>
<versionInfo>
<fileVersion>${project.version}</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>Tool for loading waypoints into DCS World</fileDescription>
<copyright>?</copyright>
<productVersion>${project.version}</productVersion>
<txtProductVersion>${project.version}</txtProductVersion>
<fileVersion>${file_version}</fileVersion>
<txtFileVersion>${tag_version}</txtFileVersion>
<fileDescription>${release_url}</fileDescription>
<copyright>GPLv3</copyright>
<productVersion>${file_version}</productVersion>
<txtProductVersion>${tag_version}</txtProductVersion>
<productName>DCS The Way</productName>
<internalName>DCS The Way</internalName>
<originalFilename>TheWay.exe</originalFilename>
Expand All @@ -112,21 +108,22 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals><goal>single</goal></goals>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<!-- create zip archive contaning the exe, README.md and lua file -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals><goal>single</goal></goals>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
</build>
</project>

0 comments on commit 7b3edfc

Please sign in to comment.