From 22b52c7c9cb041e5fac1de872a3b4711134c4f04 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Sun, 29 Sep 2024 13:22:34 +0200 Subject: [PATCH] Publish server (#56) * publish server * package name * test publish * publish server * publish server * publish server * publish server * publish server * publish server --- .github/workflows/{rust.yml => check.yml} | 2 +- .github/workflows/release.yml | 28 ++++++++++++ README.md | 45 +++++++++++++++++++ RELEASING.md | 6 +++ client/Cargo.toml | 4 ++ client/remote_client/webpack.config.js | 13 +++--- .../build-wasm-server.sh | 4 +- scripts/publish-server.sh | 21 +++++++++ server/Cargo.toml | 5 +++ 9 files changed, 119 insertions(+), 9 deletions(-) rename .github/workflows/{rust.yml => check.yml} (98%) create mode 100644 .github/workflows/release.yml create mode 100644 RELEASING.md rename server/build-wasm.sh => scripts/build-wasm-server.sh (65%) create mode 100755 scripts/publish-server.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/check.yml similarity index 98% rename from .github/workflows/rust.yml rename to .github/workflows/check.yml index 205246c9..ac8b529c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/check.yml @@ -1,4 +1,4 @@ -name: Rust +name: Check All on: push: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..18151c46 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +name: Server - Release + +on: + push: + tags: + - "v*.*.*" + +env: + node_version: 14 + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ env.node_version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ env.node_version }} + # setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED + registry-url: "https://registry.npmjs.org" + - uses: jetli/wasm-pack-action@v0.4.0 + with: + version: 'latest' + # see https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions + - run: ./scripts/publish-server.sh ${{ github.event.release.tag_name }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 3f9b49c4..2777910e 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,51 @@ diff --git a/apps/api/app/resources.ts b/apps/api/app/resources.ts console.log('received message from controller', event.data.type, JSON.parse(JSON.stringify(event.data))); switch (event.data.type) { ``` + +GameInfo.json (for now) + +```json + { + "_id": { + "game": "clash", + "version": 1 + }, + "description": "Clash of Cultures", + "engine": { + "package": { + "name": "@boardgamers/clash-server", + "version": "*" + }, + "entryPoint": "server.js" + }, + "expansions": [], + "label": "Clash of Cultures", + "meta": { + "public": true, + "needOwnership": true + }, + "options": [], + "players": [ + 2, + 3, + 4 + ], + "preferences": [], + "rules": "", + "viewer": { + "url": "http://localhost:4000/client.js", + "topLevelVariable": "clash", + "dependencies": { + "scripts": [], + "stylesheets": [] + }, + "replayable": true, + "alternate": null, + "settings": [] + } + } +``` + ## Docs diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 00000000..8aa18c37 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,6 @@ +# Releasing + +1. Go to https://github.com/boardgamers/clash/releases/new +2. Click on "Choose a tag", enter the tag name (e.g. `v0.1.0`), and click "Create a new tag". +3. Click on "Generate release notes" to auto-generate the release notes based on the commits since the last release. +4. Click on "Publish release". diff --git a/client/Cargo.toml b/client/Cargo.toml index f37b1739..dfc53fbf 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -3,6 +3,10 @@ name = "client" version = "0.1.0" edition = "2021" default-run = "local_client" +license = "MIT" +repository = "git@github.com:boardgamers/clash.git" +homepage = "https://www.boardgamers.space/" +description = "A client for Clash of Cultures" [profile.dev] debug = true diff --git a/client/remote_client/webpack.config.js b/client/remote_client/webpack.config.js index 7186b56b..05268988 100644 --- a/client/remote_client/webpack.config.js +++ b/client/remote_client/webpack.config.js @@ -1,14 +1,13 @@ const path = require('path'); module.exports = { - entry: './src/index.js', - output: { - filename: 'client.js', - path: path.resolve(__dirname, 'dist'), - }, - resolve: { + entry: './src/index.js', output: { + filename: 'client.js', path: path.resolve(__dirname, 'dist'), + }, resolve: { fallback: {"events": require.resolve("events/")} - } + }, optimization: { + minimize: true + }, }; diff --git a/server/build-wasm.sh b/scripts/build-wasm-server.sh similarity index 65% rename from server/build-wasm.sh rename to scripts/build-wasm-server.sh index 2a41424c..9b480e69 100755 --- a/server/build-wasm.sh +++ b/scripts/build-wasm-server.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash -set -e +set -euo pipefail +pushd server wasm-pack build --target nodejs +popd echo "Done!" diff --git a/scripts/publish-server.sh b/scripts/publish-server.sh new file mode 100755 index 00000000..9d20479a --- /dev/null +++ b/scripts/publish-server.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -euo pipefail + +VERSION=$1 +if [ -z "$VERSION" ]; then + echo "Usage: $0 " + exit 1 +fi + +echo "Building server..." +./scripts/build-wasm-server.sh + +echo "Publishing server..." +pushd server +sed -i 's#"name": "server"#"name": "@boardgamers/clash-server"#' pkg/package.json +sed -i "s#\"version\": \"0.1.0\"#\"version\": \"$VERSION\"#" pkg/package.json +wasm-pack publish --access public +popd + +echo "Done!" diff --git a/server/Cargo.toml b/server/Cargo.toml index 9b1ae38f..5ad907be 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -2,6 +2,11 @@ name = "server" version = "0.1.0" edition = "2021" +license = "MIT" +repository = "git@github.com:boardgamers/clash.git" +homepage = "https://www.boardgamers.space/" +description = "A server for Clash of Cultures" + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html