Skip to content

Instantly share code, notes, and snippets.

@NobleDraconian
Forked from boatbomber/publish.yml
Created February 18, 2022 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NobleDraconian/2c71172b66e98462aa20673d3dff2fc8 to your computer and use it in GitHub Desktop.
Save NobleDraconian/2c71172b66e98462aa20673d3dff2fc8 to your computer and use it in GitHub Desktop.
A publishing workflow for Roblox projects
## Welcome to boatbomber's publish workflow.
# You'll need a few things in your GitHub Action secrets for this to work:
# - ROBLOSECURITY : A cookie of a Roblox account (used to install Studio for testing)
# - RBXID : Another cookie from the account (also used in Studio install)
# - PUBLISHCLOUD : A Roblox OpenCloud API key with Write permission in Place Management for your game
# This workflow assumes that you have:
# - A `foreman.toml` with rojo, selene, run-in-roblox, and darklua
# - A `default.project.json` that builds a place file
# - A `tests.project.json` that builds a place file
# - A `tests/TestRunner.lua` that runs your tests
# You'll also need to set the env variables below to your correct IDs for place/universe, of course.
name: Publish
env:
TESTING_UNIVERSE: '731905475'
TESTING_PLACE: '2083920096'
PRODUCTION_UNIVERSE: '537069295'
PRODUCTION_PLACE: '1334669864'
on:
workflow_dispatch:
inputs:
place:
description: 'Pick where to publish to'
required: true
default: 'Testing'
type: choice
options:
- Testing
- Production
requireTest:
description: 'Require passing tests before publishing'
required: false
type: boolean
shouldProcess:
description: 'Process and minify source code before publishing'
required: false
type: boolean
jobs:
Deployment:
runs-on: windows-latest
steps:
# Logging
- name: Log chosen inputs
shell: bash
run: |
echo "Publish Target: ${{ github.event.inputs.place }}"
echo "Require Tests Passing: ${{ github.event.inputs.requireTest }}"
echo "Process Source Code: ${{ github.event.inputs.shouldProcess }}"
# Dependencies
- name: Checkout repository
uses: actions/checkout@v2
- name: Check for cookies and keys
shell: bash
run: |
if [ -z "${{ secrets.ROBLOSECURITY }}" ]; then echo 'Missing ROBLOSECURITY secret!'; exit 1; else echo 'Found ROBLOSECURITY secret...'; fi
if [ -z "${{ secrets.RBXID }}" ]; then echo 'Missing RBXID secret!'; exit 1; else echo 'Found RBXID secret...'; fi
if [ -z "${{ secrets.PUBLISHCLOUD }}" ]; then echo 'Missing PUBLISHCLOUD secret!'; exit 1; else echo 'Found PUBLISHCLOUD secret...'; fi
- name: Foreman installation
uses: rojo-rbx/setup-foreman@v1
with:
version: "^1.0.3"
token: ${{ secrets.GITHUB_TOKEN }}
# Testing
- name: Setup Studio cookies
if: github.event.inputs.requireTest == 'true'
run: REG ADD HKCU\Software\RobloxStudioBrowser\roblox.com /t REG_SZ /v .RBXID /d "${{ secrets.RBXID }}"
- name: Studio installation
if: github.event.inputs.requireTest == 'true'
uses: OrbitalOwen/roblox-win-installer-action@1.1
with:
cookie: ${{ secrets.ROBLOSECURITY }} # Cookie for Un1tTest_Act10n account
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
if: github.event.inputs.requireTest == 'true'
run: |
echo 'Running linter...'
selene --config selene.toml src/client src/server src/first src/shared/Util src/shared/Data
echo 'Running tests...'
rojo build tests.project.json -o ./tests/test.rbxl
run-in-roblox --place ./tests/test.rbxl --script ./tests/TestRunner.lua
# Source code processing
- name: Process & minify source code
if: github.event.inputs.shouldProcess == 'true'
continue-on-error: true
run: |
echo 'Processing & minifying source code...'
darklua process src src --format retain-lines
# Deployment
- name: Build the project
run: rojo build default.project.json -o build.rbxl
- name: Upload the build as an action artifact
uses: actions/upload-artifact@v2
with:
name: Project Build
path: build.rbxl
- name: Publish to Roblox
shell: bash
run: |
if [ ${{ github.event.inputs.place }} == 'Production' ]; then universeId=$PRODUCTION_UNIVERSE; else universeId=$TESTING_UNIVERSE; fi
if [ ${{ github.event.inputs.place }} == 'Production' ]; then placeId=$PRODUCTION_PLACE; else placeId=$TESTING_PLACE; fi
echo "Publishing to $universeId/$placeId"
curl --verbose --location --request POST "https://apis.roblox.com/universes/v1/$universeId/places/$placeId/versions?versionType=Published" \
--header "x-api-key: ${{ secrets.PUBLISHCLOUD }}" \
--header 'Content-Type: application/octet-stream' \
--data-binary @build.rbxl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment