init #91
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: Release Server | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
env: | |
url: https://kotlingames.shop | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
release: | |
permissions: write-all | |
strategy: | |
matrix: | |
os: [ ubuntu-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- name: set properties value of server | |
run: | | |
setProperty(){ | |
awk -v pat="^$1=" -v value="$1=$2" '{ if ($0 ~ pat) print value; else print $0; }' $3 > $3.tmp | |
mv $3.tmp $3 | |
} | |
setProperty "server" "${{ env.url }}" "gradle.properties" | |
setProperty "version" "v0.0.${{github.run_number}}" "gradle.properties" | |
- run: git tag ${{github.run_number}} | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Buid JS bundle | |
run: | | |
./gradlew :client:jsBrowserProductionWebpack | |
- name: server.zip | |
run: ./gradlew :server:distZip | |
- name: release | |
uses: marvinpinto/action-automatic-releases@latest | |
with: | |
title: "Build #${{github.run_number}}" | |
automatic_release_tag: "${{github.run_number}}" | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
files: server/build/distributions/server.zip | |
prerelease: false | |
- shell: bash | |
run: | | |
curl -d "${{ secrets.ADMIN_KEY }}" -X POST ${{ env.url }}/shutdown | |
buildExe: | |
name: Release .exe | |
runs-on: windows-latest | |
needs: release | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- name: set properties value of server | |
run: | | |
type nul > Prop.java | |
echo "import java.io.File;import java.io.FileInputStream;import java.util.Arrays;import java.util.Iterator;import java.util.Properties;public class Prop {public static void main(String[] args) throws Exception {Iterator<String> iterator = Arrays.stream(args).iterator();if (!iterator.hasNext()) return;String fileName = iterator.next();File file = new File(fileName);Properties props = new Properties();props.load(new FileInputStream(file));while (true) {if (!iterator.hasNext()) return;String key = iterator.next();if (!iterator.hasNext()) return;String value = iterator.next();props.setProperty(key, value);}}}" > Prop.java | |
java Prop.java gradle.properties server ${{ env.url }} | |
java Prop.java gradle.properties version v0.0.${{github.run_number}} | |
- run: git tag ${{github.run_number}} | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Buid JS bundle | |
run: | | |
./gradlew :client:linkReleaseExecutableMingwX64 | |
- name: Build | |
run: cargo build --release | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: client/build | |
tag: ${{ github.ref }} | |
overwrite: true |