Skip to content

Commit

Permalink
vpmリポジトリに変更を反映するように
Browse files Browse the repository at this point in the history
  • Loading branch information
m-hayabusa committed Jul 12, 2023
1 parent 204bda1 commit d4c6929
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/build-listing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Build Repo Listing

on:
workflow_dispatch:
workflow_run:
workflows: [Build Release]
types:
- completed
release:
types: [published, created, edited, unpublished, deleted, released]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
id-token: write

# Allow one concurrent deployment
concurrency:
group: "repo"
cancel-in-progress: true

env:
vpmRepository: https://vpm.nekomimi.studio/index.json
pathToCi: ci

jobs:
build-listing:
name: build-listing
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3 # check out this repo

- name: m-hayabusa/vpm-repo
uses: actions/checkout@v3
with:
repository: m-hayabusa/vpm-repo
path: ${{env.pathToCi}}/vpm-repo
clean: false

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Merge Package Version Listing
run: >
node -e '
const fs = require("fs");
const package = JSON.parse(fs.readFileSync("./package.json"));
const basepkg = JSON.parse(fs.readFileSync("${{env.pathToCi}}/vpm-repo/index.json"));
package.url = "https://github.com/${{ github.repository }}/releases/download/" + package.version + "/" + package.name + "-" + package.version + ".zip?";
if (basepkg.packages[package.name] === undefined) basepkg.packages[package.name] = {};
if (basepkg.packages[package.name].versions === undefined) basepkg.packages[package.name].versions = {};
basepkg.packages[package.name].versions[package.version] = package;
fs.writeFileSync("${{env.pathToCi}}/vpm-repo/index.json", JSON.stringify(basepkg, undefined, " "));
'
- name: Get version and name
run: >
node -e '
const fs = require("fs");
const package = JSON.parse(fs.readFileSync("./package.json"));
console.log("package_version=" + package.version);
console.log("package_displayName=" + package.displayName);
' >> $GITHUB_ENV
- name: Create installer
run: >
mkdir ${{env.pathToCi}}/vpmPackage;
wget https://github.com/anatawa12/VPMPackageAutoInstaller/releases/latest/download/creator.mjs -O ${{env.pathToCi}}/vpmPackage/creator.mjs;
node -e '
const fs = require("fs");
const package = JSON.parse(fs.readFileSync("./package.json"));
const config = {};
config.vpmRepositories = ["${{env.vpmRepository}}"];
config.vpmDependencies = package.vpmDependencies;
if (config.vpmDependencies == undefined) config.vpmDependencies = {};
config.vpmDependencies[package.name] = package.version;
fs.writeFileSync("${{env.pathToCi}}/vpmPackage/config.json", JSON.stringify(config));
';
node ${{env.pathToCi}}/vpmPackage/creator.mjs ${{env.pathToCi}}/vpmPackage/config.json "${{env.pathToCi}}/vpm-repo/installer/${{env.package_displayName}}-installer.unitypackage";
- name: Pushes to another repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with:
source-directory: ${{env.pathToCi}}/vpm-repo
destination-github-username: "m-hayabusa"
destination-repository-name: "vpm-repo"
user-email: [email protected]
target-branch: main
commit-message: ${{env.package_displayName}} v${{env.package_version}}
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build Release

on:
workflow_dispatch:
push:
branches: main

env:
packageName: "studio.nekomimi.parser.xml"

jobs:
check:
runs-on: ubuntu-latest
outputs:
run: ${{ steps.tag.outputs.tag != steps.version.outputs.prop }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "get latest tag"
id: tag
run: echo tag=$(git describe --tags --abbrev=0) >> $GITHUB_OUTPUT

- name: get version
id: version
uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31
with:
path: "package.json"
prop_path: "version"

build:
needs: [check]
if: ${{ needs.check.outputs.run == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: get version
id: version
uses: notiz-dev/github-action-json-property@7c8cf5cc36eb85d8d287a8086a39dac59628eb31
with:
path: "package.json"
prop_path: "version"

- 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: "."
filename: "${{ env.zipFile }}"

- run: find . -name \*.meta >> metaList

- name: Create UnityPackage
uses: pCYSl5EDgo/create-unitypackage@cfcd3cf0391a5ef1306342794866a9897c32af0b
with:
package-path: ${{ env.unityPackage }}
include-files: metaList

- name: Make Release
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
with:
tag_name: ${{ steps.version.outputs.prop }}
files: |
${{ env.zipFile }}
${{ env.unityPackage }}
./package.json

0 comments on commit d4c6929

Please sign in to comment.