Skip to content

Commit

Permalink
Add autopublish
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed Dec 12, 2023
1 parent d26aed4 commit e85f8ac
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.0
with:
node-version: ${{ env.node_version }}

Expand All @@ -45,7 +45,7 @@ jobs:
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.0
with:
node-version: ${{ env.node_version }}

Expand Down
131 changes: 131 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# SPDX-FileCopyrightText: 2021 Johannes Loher
#
# SPDX-License-Identifier: MIT

name: Publish

on:
push:
tags:
- "*.*.*"

env:
node_version: 16

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install node
uses: actions/[email protected]
with:
node-version: ${{ env.node_version }}

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: .npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install dependencies
run: npm ci --cache .npm --prefer-offline

- name: Lint
run: npm run lint

build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install node
uses: actions/[email protected]
with:
node-version: ${{ env.node_version }}

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: .npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install dependencies
run: npm ci --cache .npm --prefer-offline

- name: Build
run: npm run build
env:
NODE_ENV: production

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

reuse:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: REUSE Compliance Check
uses: fsfe/reuse-action@v2

publish:
needs:
- lint
- build
- reuse
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install node
uses: actions/[email protected]
with:
node-version: ${{ env.node_version }}

- name: Download production artifacts for publication
uses: actions/download-artifact@v3
with:
name: dist
path: dist

- name: Create zip file
working-directory: ./dist
run: zip -r ../module.zip .

- name: Extract version
run: |
echo "::set-output name=version::$(jq -r '.version' package.json)"
id: extract_version

- name: Create release
id: create_version_release
uses: ncipollo/release-action@v1
with:
allowUpdates: false
name: ${{ steps.extract_version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "./module.json, ./module.zip"

- name: Publish to Foundry Admin
uses: Varriount/[email protected]
with:
username: ${{ secrets.FVTT_USERNAME }}
password: ${{ secrets.FVTT_PASSWORD }}
module-id: ${{ secrets.FVTT_PACKAGE_ID }}
manifest-url: https://github.com/${{ github.repository }}/releases/download/v${{ steps.extract_version.outputs.version }}/module.json
manifest-file: ./module.json
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.0
with:
node-version: ${{ env.node_version }}

Expand All @@ -46,7 +46,7 @@ jobs:
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.0
with:
node-version: ${{ env.node_version }}

Expand All @@ -70,7 +70,7 @@ jobs:
id: sub_manifest_link_version
uses: microsoft/variable-substitution@v1
with:
files: 'src/${{ env.package_type }}.json'
files: "src/${{ env.package_type }}.json"
env:
version: ${{ steps.get_version.outputs.version-without-v }}
url: https://github.com/${{ github.repository }}
Expand All @@ -81,7 +81,7 @@ jobs:
run: npm run build

- name: Archive production artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
Expand All @@ -96,7 +96,7 @@ jobs:
uses: actions/checkout@v4

- name: Download production artifacts for publication
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: dist
path: dist
Expand All @@ -112,6 +112,6 @@ jobs:
allowUpdates: true
name: ${{ github.event.release.name }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: './dist/${{ env.package_type }}.json, ./${{ env.package_type }}.zip'
artifacts: "./dist/${{ env.package_type }}.json, ./${{ env.package_type }}.zip"
tag: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}

0 comments on commit e85f8ac

Please sign in to comment.