forked from mumble-voip/mumble-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from alifeee/release
Create automated release action
- Loading branch information
Showing
7 changed files
with
261 additions
and
75 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: | ||
- released | ||
|
||
jobs: | ||
verify_version_number: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: get_version | ||
name: Get version | ||
uses: jannemattila/get-version-from-tag@v1 | ||
|
||
- name: Verify version number | ||
run: | | ||
set -e | ||
grep -F '"version": "${{ steps.get_version.outputs.version }}"' factorio/info.json | ||
grep -F 'VERSION "${{ steps.get_version.outputs.version }}"' mumble/CMakeLists.txt | ||
grep -F "<version>${{ steps.get_version.outputs.version }}</version>" mumble/manifest.xml | ||
grep -F 'char *VERSION = "${{ steps.get_version.outputs.version }}";' mumble/plugin.c | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | ||
fail-fast: false | ||
|
||
# Set up a matrix to run the following 3 configurations: | ||
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> | ||
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator> | ||
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> | ||
# | ||
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
build_type: [Release] | ||
c_compiler: [gcc, clang, cl] | ||
include: | ||
- os: windows-latest | ||
c_compiler: cl | ||
cpp_compiler: cl | ||
- os: ubuntu-latest | ||
c_compiler: gcc | ||
cpp_compiler: g++ | ||
- os: ubuntu-latest | ||
c_compiler: clang | ||
cpp_compiler: clang++ | ||
exclude: | ||
- os: windows-latest | ||
c_compiler: gcc | ||
- os: windows-latest | ||
c_compiler: clang | ||
- os: ubuntu-latest | ||
c_compiler: cl | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set reusable strings | ||
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | ||
id: strings | ||
shell: bash | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
echo "build-input-dir=${{ github.workspace }}/mumble" >> "$GITHUB_OUTPUT" | ||
- name: Configure CMake | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: > | ||
cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | ||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
-S ${{ steps.strings.outputs.build-input-dir }} | ||
- name: Build | ||
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | ||
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | ||
|
||
- name: Upload a Build Artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: build | ||
path: ${{ steps.strings.outputs.build-output-dir }} | ||
|
||
bundle_mumble: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: build | ||
path: build | ||
|
||
- name: Bundle | ||
run: | | ||
mv build/libfactorio_linux_x86_64.so libplugin.so | ||
mv build/Release/plugin.dll plugin.dll | ||
mv mumble/manifest.xml manifest.xml | ||
zip -MM factorio.mumble_plugin manifest.xml libplugin.so plugin.dll | ||
- name: Upload a Build Artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: bundle | ||
path: factorio.mumble_plugin | ||
|
||
bundle_factorio: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- id: get_version | ||
name: Get version | ||
uses: jannemattila/get-version-from-tag@v1 | ||
|
||
- name: Bundle | ||
run: | | ||
cp -r factorio/ proximity-chat/ | ||
zip -r proximity-chat_${{ steps.get_version.outputs.version }}.zip proximity-chat | ||
- name: Upload a Build Artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: proximity-chat_${{ steps.get_version.outputs.version }}.zip | ||
path: proximity-chat_${{ steps.get_version.outputs.version }}.zip | ||
|
||
add_release_files: | ||
needs: [bundle_mumble, bundle_factorio] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- id: get_version | ||
name: Get version | ||
uses: jannemattila/get-version-from-tag@v1 | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: bundle | ||
path: bundle | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: proximity-chat_${{ steps.get_version.outputs.version }}.zip | ||
path: proximity-chat_${{ steps.get_version.outputs.version }}.zip | ||
|
||
- name: Get release | ||
id: get_release | ||
uses: bruceadams/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
- name: Upload mumble plugin | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.get_release.outputs.upload_url }} | ||
asset_path: bundle/factorio.mumble_plugin | ||
asset_name: factorio.mumble_plugin | ||
asset_content_type: application/zip | ||
|
||
- name: Upload factorio mod | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.get_release.outputs.upload_url }} | ||
asset_path: proximity-chat_${{ steps.get_version.outputs.version }}.zip | ||
asset_name: proximity-chat_${{ steps.get_version.outputs.version }}.zip | ||
asset_content_type: application/zip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"name": "mumble-positional-audio", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"title": "Mumble Positional Audio", | ||
"author": "alifeee", | ||
"factorio_version": "1.1", | ||
"dependencies": ["base >= 1.1"], | ||
"description": "This mod allows integration with the Mumble Factorio plugin, allowing proximity chat in multiplayer games." | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include "logfile.c" | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
char *homeDir = get_home_dir(); | ||
printf("Home dir: %s\n\n", homeDir); | ||
|
||
if (is_factorio_logfile_there()) | ||
{ | ||
printf("Factorio logfile is present\n\n"); | ||
} | ||
else | ||
{ | ||
printf("Factorio logfile is not present. Terminating...\n"); | ||
return 0; | ||
} | ||
|
||
float x, y, z; | ||
int player, surface; | ||
char *server; | ||
size_t server_len; | ||
|
||
parse_factorio_logfile(&x, &y, &z, &player, &surface, &server, &server_len); | ||
|
||
// log variables | ||
printf("x: %f\n", x); | ||
printf("y: %f\n", y); | ||
printf("z: %f\n", z); | ||
printf("player: %d\n", player); | ||
printf("surface: %d\n", surface); | ||
printf("server: %s\n", server); | ||
|
||
// combine surface and server | ||
char *context_str = malloc(server_len + 1 + 1 + 1); | ||
strcpy(context_str, server); | ||
strcat(context_str, "/"); | ||
char surface_str[12]; | ||
sprintf(surface_str, "%d", surface); | ||
strcat(context_str, surface_str); | ||
char *context = context_str; | ||
|
||
printf("context: %s\n", context_str); | ||
|
||
// get_file_modified_time | ||
time_t modified_time = get_factorio_file_modified_time(); | ||
printf("modified time: %ld\n", modified_time); | ||
// compare to time now | ||
time_t now = time(NULL); | ||
printf("now: %ld\n", now); | ||
// difference | ||
time_t diff = now - modified_time; | ||
printf("diff: %ld\n", diff); | ||
if (diff > 20) | ||
{ | ||
printf("More than 20 seconds ago!\n"); | ||
} | ||
|
||
// is recent? | ||
if (is_factorio_logfile_recent(2)) | ||
{ | ||
printf("Factorio logfile is recent\n"); | ||
} | ||
else | ||
{ | ||
printf("Factorio logfile is not recent.\n"); | ||
} | ||
|
||
return 0; | ||
} |
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
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