Skip to content

Commit

Permalink
Merge pull request vrchat-community#13 from dustuu/reduced-features
Browse files Browse the repository at this point in the history
Added repository variable configuration and cleaned up GitHub Action workflows
  • Loading branch information
momo-the-monster authored Oct 2, 2023
2 parents 483e898 + 314918f commit d9cf13f
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 55 deletions.
46 changes: 28 additions & 18 deletions .github/workflows/build-listing.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Build Repo Listing

env:
CurrentPackageName: com.vrchat.demo-template
listPublishDirectory: Website
pathToCi: ci

Expand All @@ -27,6 +26,7 @@ concurrency:

jobs:

# Build the VPM Listing Website and deploy to GitHub Pages
build-listing:
name: build-listing
environment:
Expand All @@ -35,34 +35,44 @@ jobs:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3 # check out this repo
- uses: actions/checkout@v3 # check out automation repo
# Checkout Local Repository
- name: Checkout Local Repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac

# Checkout Automation Repository without removing prior checkouts
- name: Checkout Automation Repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
with:
repository: vrchat-community/package-list-action
path: ${{env.pathToCi}}
clean: false # otherwise the local repo will no longer be checked out

path: ${{ env.pathToCi }}
clean: false

# Load cached data from previous runs
- name: Restore Cache
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
with:
path: |
${{env.pathToCi}}/.nuke/temp
${{ env.pathToCi }}/.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}


# Build Package Version Listing with Nuke
- name: Build Package Version Listing
run: ${{env.pathToCi}}/build.cmd BuildRepoListing --root ${{env.pathToCi}} --list-publish-directory $GITHUB_WORKSPACE/${{env.listPublishDirectory}} --current-package-name ${{env.CurrentPackageName}}
run: ${{ env.pathToCi }}/build.cmd BuildRepoListing --root ${{ env.pathToCi }} --list-publish-directory $GITHUB_WORKSPACE/${{ env.listPublishDirectory }} --current-package-name ${{ vars.PACKAGE_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# Prepare for GitHub Pages deployment
- name: Setup Pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/configure-pages@f156874f8191504dae5b037505266ed5dda6c382

# Upload the VPM Listing Website to GitHub Pages artifacts
- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@a753861a5debcf57bf8b404356158c8e1e33150c
with:
path: ${{env.listPublishDirectory}}

path: ${{ env.listPublishDirectory }}

# Deploy the uploaded VPM Listing Website to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@9dbe3824824f8a1377b8e298bafde1a50ede43e5
88 changes: 60 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,85 @@ name: Build Release
on:
workflow_dispatch:

env:
packageName: "com.vrchat.demo-template"
jobs:

# Validate Repository Configuration
config:
runs-on: ubuntu-latest
outputs:
config_package: ${{ steps.config_package.outputs.configPackage }}
steps:

permissions:
contents: write
# Ensure that required repository variable has been created for the Package
- name: Validate Package Config
id: config_package
run: |
if [ "${{ vars.PACKAGE_NAME }}" != "" ]; then
echo "configPackage=true" >> $GITHUB_OUTPUT;
else
echo "configPackage=false" >> $GITHUB_OUTPUT;
fi
jobs:
# Build and release the Package
# If the repository is not configured properly, this job will be skipped
build:
needs: config
runs-on: ubuntu-latest
permissions:
contents: write
env:
packagePath: Packages/${{ vars.PACKAGE_NAME }}
if: needs.config.outputs.config_package == 'true'
steps:


# Checkout Local Repository
- name: Checkout
uses: actions/checkout@v3

- name: get version
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac

# Get the Package version based on the package.json file
- name: Get Version
id: version
uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31
uses: zoexx/github-action-json-file-properties@b9f36ce6ee6fe2680cd3c32b2c62e22eade7e590
with:
path: "Packages/${{env.packageName}}/package.json"
file_path: "${{ env.packagePath }}/package.json"
prop_path: "version"

# Configure the Environment Variables needed for releasing the Package
- name: Set Environment Variables
run: |
echo "zipFile=${{ env.packageName }}-${{ steps.version.outputs.prop }}".zip >> $GITHUB_ENV
echo "unityPackage=${{ env.packageName }}-${{ steps.version.outputs.prop }}.unitypackage" >> $GITHUB_ENV
- name: Create Zip
uses: thedoctor0/zip-release@09336613be18a8208dfa66bd57efafd9e2685657
with:
type: "zip"
directory: "Packages/${{env.packageName}}/"
filename: "../../${{env.zipFile}}" # make the zip file two directories up, since we start two directories in above

- run: find "Packages/${{env.packageName}}/" -name \*.meta >> metaList

echo "zipFile=${{ vars.PACKAGE_NAME }}-${{ steps.version.outputs.value }}".zip >> $GITHUB_ENV
echo "unityPackage=${{ vars.PACKAGE_NAME }}-${{ steps.version.outputs.value }}.unitypackage" >> $GITHUB_ENV
echo "version=${{ steps.version.outputs.value }}" >> $GITHUB_ENV
# Zip the Package for release
- name: Create Package Zip
working-directory: "${{ env.packagePath }}"
run: zip -r "${{ github.workspace }}/${{ env.zipFile }}" .

# Build a list of .meta files for future use
- name: Track Package Meta Files
run: find "${{ env.packagePath }}/" -name \*.meta >> metaList

# Make a UnityPackage version of the Package for release
- name: Create UnityPackage
uses: pCYSl5EDgo/create-unitypackage@cfcd3cf0391a5ef1306342794866a9897c32af0b
with:
package-path: ${{ env.unityPackage }}
include-files: metaList



# Make a release tag of the version from the package.json file
- name: Create Tag
id: tag_version
uses: rickstaa/action-create-tag@88dbf7ff6fe2405f8e8f6c6fdfd78829bc631f83
with:
tag: "${{ env.version }}"

# Publish the Release to GitHub
- name: Make Release
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
tag_name: ${{ steps.version.outputs.prop }}
files: |
${{ env.zipFile }}
${{ env.unityPackage }}
Packages/${{ env.packageName }}/package.json
${{ env.packagePath }}/package.json
tag_name: ${{ env.version }}
2 changes: 1 addition & 1 deletion Packages/com.vrchat.demo-template/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.vrchat.demo-template",
"displayName": "VRChat Example Package",
"version": "0.0.3",
"version": "0.0.6",
"unity": "2019.4",
"description": "Simple Package for testing Automation",
"vrchatVersion": "2022.1.1",
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ to start a new GitHub project based on this template.
## 🚇 Migrating Assets Package
Full details at [Converting Assets to a VPM Package](https://vcc.docs.vrchat.com/guides/convert-unitypackage)

## Working on Your Package
## ✏️ Working on Your Package

* Delete the "Packages/com.vrchat.demo-template" directory or reuse it for your own package.
* If you reuse the package, don't forget to rename it!
Expand All @@ -31,13 +31,13 @@ Full details at [Converting Assets to a VPM Package](https://vcc.docs.vrchat.com
* When you're ready, commit and push your changes.
* Once you've set up the automation as described below, you can easily publish new versions.

## Setting up the Automation
## 🤖 Setting up the Automation

You'll need to make a change in [release.yml](.github/workflows/release.yml):
* Change the `packageName` property on line 10 to include the name of your package, like `packageName: "com.vrchat.demo-template"`
Create a repository variable with the name and value described below.
For details on how to create repository variables, see [Creating Configuration Variables for a Repository](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository).
Make sure you are creating a **repository variable**, and not a **repository secret**.

You'll also need to make a change to [build-listing.yml](.github/workflows/build-listing.yml):
* Change `CurrentPackageName` in line 4 from `com.vrchat.demo-template` to your own package name.
* `PACKAGE_NAME`: the name of your package, like `com.vrchat.demo-template`.

Finally, go to the "Settings" page for your repo, then choose "Pages", and look for the heading "Build and deployment". Change the "Source" dropdown from "Deploy from a branch" to "GitHub Actions".

Expand All @@ -57,11 +57,11 @@ You can make a release by running the [Build Release](.github/workflows/release.

Whenever you make a change to a release - manually publishing it, or manually creating, editing or deleting a release, the [Build Repo Listing](.github/workflows/build-listing.yml) action will make a new index of all the releases available, and publish them as a website hosted fore free on [GitHub Pages](https://pages.github.com/). This listing can be used by the VPM to keep your package up to date, and the generated index page can serve as a simple landing page with info for your package. The URL for your package will be in the format `https://username.github.io/repo-name`.

## 🏠 Customizing the Landing Page
## 🏠 Customizing the Landing Page (Optional)

The action which rebuilds the listing also publishes a landing page. The source for this page is in `Website/index.html`. The automation system uses [Scriban](https://github.com/scriban/scriban) to fill in the objects like `{{ this }}` with information from the latest release's manifest, so it will stay up-to-date with the name, id and description that you provide there. You are welcome to modify this page however you want - just use the existing `{{ template.objects }}` to fill in that info wherever you like. The entire contents of your "Website" folder are published to your GitHub Page each time.

## Technical Stuff
## 💻 Technical Stuff

You are welcome to make your own changes to the automation process to make it fit your needs, and you can create Pull Requests if you have some changes you think we should adopt. Here's some more info on the included automation:

Expand Down

0 comments on commit d9cf13f

Please sign in to comment.