From 0c337a58dd631a92c0ab1db4a41c3af7ab965952 Mon Sep 17 00:00:00 2001 From: Dustuu Date: Sat, 23 Sep 2023 22:43:50 +0800 Subject: [PATCH] Added repository variable configuration and small workflow cleanups --- .github/workflows/build-listing.yml | 46 ++++++----- .github/workflows/release.yml | 78 ++++++++++++------- .../com.vrchat.demo-template/package.json | 2 +- README.md | 16 ++-- 4 files changed, 89 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build-listing.yml b/.github/workflows/build-listing.yml index 0a6723a..8abce13 100644 --- a/.github/workflows/build-listing.yml +++ b/.github/workflows/build-listing.yml @@ -1,7 +1,6 @@ name: Build Repo Listing env: - CurrentPackageName: com.vrchat.demo-template listPublishDirectory: Website pathToCi: ci @@ -27,6 +26,7 @@ concurrency: jobs: + # Build the VPM Listing Website and deploy to GitHub Pages build-listing: name: build-listing environment: @@ -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@f43a0e5ff2bd294095638e18286ca9a3d1956744 + + # Checkout Automation Repository without removing prior checkouts + - name: Checkout Automation Repository + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 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@f5ce41475b483ad7581884324a6eca9f48f8dcc7 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@f27bcc15848fdcdcc02f01754eb838e44bcf389b \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 60a288e..e37dc5d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,59 +3,85 @@ name: Build Release on: workflow_dispatch: -env: - packageName: "com.vrchat.demo-template" +jobs: -permissions: - contents: write + # Validate Repository Configuration + config: + runs-on: ubuntu-latest + outputs: + config_package: ${{ steps.config_package.outputs.configPackage }} + steps: -jobs: + # 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 + + # 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@f43a0e5ff2bd294095638e18286ca9a3d1956744 + + # Get the Package version based on the package.json file + - name: Get Version id: version uses: zoexx/github-action-json-file-properties@b9f36ce6ee6fe2680cd3c32b2c62e22eade7e590 with: - file_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.value }}".zip >> $GITHUB_ENV - echo "unityPackage=${{ env.packageName }}-${{ steps.version.outputs.value }}.unitypackage" >> $GITHUB_ENV + 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 - - - 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 - + + # 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@07b918ecbf94359b859f25f7a70553a84e804923 with: - tag: "${{env.version}}" - + tag: "${{ env.version }}" + + # Publish the Release to GitHub - name: Make Release uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 with: files: | ${{ env.zipFile }} ${{ env.unityPackage }} - Packages/${{ env.packageName }}/package.json - tag_name: ${{env.version}} + ${{ env.packagePath }}/package.json + tag_name: ${{ env.version }} \ No newline at end of file diff --git a/Packages/com.vrchat.demo-template/package.json b/Packages/com.vrchat.demo-template/package.json index 2c2280a..7ce0d05 100644 --- a/Packages/com.vrchat.demo-template/package.json +++ b/Packages/com.vrchat.demo-template/package.json @@ -1,7 +1,7 @@ { "name": "com.vrchat.demo-template", "displayName": "VRChat Example Package", - "version": "0.0.3", + "version": "0.0.4", "unity": "2019.4", "description": "Simple Package for testing Automation", "vrchatVersion": "2022.1.1", diff --git a/README.md b/README.md index 2c55be2..39f577a 100644 --- a/README.md +++ b/README.md @@ -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! @@ -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". @@ -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: