Skip to content

Commit

Permalink
Update project 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed Jun 17, 2024
1 parent edfaf80 commit 93446e5
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 176 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# SPDX-FileCopyrightText: 2022 Johannes Loher
#
# SPDX-License-Identifier: MIT

name: Checks

on:
- push
- pull_request

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
54 changes: 0 additions & 54 deletions .github/workflows/main.yml

This file was deleted.

217 changes: 147 additions & 70 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,151 @@
# Thanks to Calego / ElfFriend (https://github.com/ElfFriend-DnD/) for the initial reference for this GH Action.
name: Module Tag / Release
# SPDX-FileCopyrightText: 2022 Johannes Loher
#
# SPDX-License-Identifier: MIT

name: Release

on:
push:
tags:
- "v*"
release:
types: [published]

env:
package_type: module
node_version: 16

jobs:
build:
environment: default
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"

- name: Install Dependencies
run: |
npm install -g yarn
yarn install
- name: Get Release Version From Tag
id: get_version
uses: battila7/get-version-action@v2

- name: Prepare Module Manifest
id: sub_manifest_link_version
uses: microsoft/variable-substitution@v1
with:
files: "src/module.json"
env:
version: ${{steps.get_version.outputs.version-without-v}}
manifest: https://github.com/${{github.repository}}/releases/latest/download/module.json
download: https://github.com/${{github.repository}}/releases/download/${{steps.get_version.outputs.version}}/module.zip

- name: Build Release
run: |
set -euo pipefail
npm run-script build
npm run-script package
# Generate changelog for release body
- name: Generate Changelog
uses: scottbrenner/generate-changelog-action@f17b985298496cf8df35aa1104091c51e7bfea95
env:
REPO: ${{ github.repository }}

# Create a release for this specific version
- name: Create Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
name: ${{ env.RELEASE_VERSION }}
body: |
${{ steps.Changelog.outputs.changelog }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "./src/module.json,./package/module.zip"
tag: ${{ env.RELEASE_VERSION }}

# Publish the release to FoundryVTT's package repository.
# - name: FoundryVTT AutoPublish
# uses: Varriount/[email protected]
# with:
# username: ${{ secrets.FOUNDRY_ADMIN_USER }}
# password: ${{ secrets.FOUNDRY_ADMIN_PW }}
# module-id: 1189
# manifest-url: https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_VERSION }}/module.json
# manifest-file: ./src/module.json
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: Extract tag version number
id: get_version
uses: battila7/get-version-action@v2

- name: Substitute Manifest and Download Links For Versioned Ones
id: sub_manifest_link_version
uses: microsoft/variable-substitution@v1
with:
files: "src/${{ env.package_type }}.json"
env:
version: ${{ steps.get_version.outputs.version-without-v }}
url: https://github.com/${{ github.repository }}
manifest: https://github.com/${{ github.repository }}/releases/latest/download/${{ env.package_type }}.json
download: https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/${{ env.package_type }}.zip

- name: Build
run: npm run build

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

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

- 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 ../${{ env.package_type }}.zip .

- name: Create release
id: create_version_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
name: ${{ github.event.release.name }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "./dist/${{ env.package_type }}.json, ./${{ env.package_type }}.zip"
tag: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}

- name: Get Module ID
id: moduleID
uses: notiz-dev/github-action-json-property@release
with:
path: "./dist/${{ env.package_type }}.json"
prop_path: "id"

- name: Get mininum
id: minimum
uses: notiz-dev/github-action-json-property@release
with:
path: "./dist/${{ env.package_type }}.json"
prop_path: "compatibility.minimum"

- name: Get verified
id: verified
uses: notiz-dev/github-action-json-property@release
with:
path: "./dist/${{ env.package_type }}.json"
prop_path: "compatibility.verified"

- name: Extract tag version number
id: get_version
uses: battila7/get-version-action@v2

- name: Foundry Release API
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.foundryvtt.com/_api/packages/release_version"
method: "POST"
customHeaders: '{"Content-Type": "application/json", "Authorization" : "${{ secrets.FOUNDRY_KEY }}"}'
data: '{"id": "${{ steps.moduleID.outputs.prop }}", "release": {"version": "${{ steps.get_version.outputs.version-without-v }}", "manifest": "https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/${{ env.package_type }}.json", "notes": "https://github.com/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }}/", "compatibility" : {"minimum": "${{ steps.minimum.outputs.prop }}", "verified": "${{ steps.verified.outputs.prop }}"}}}'
preventFailureOnNoResponse: true
45 changes: 0 additions & 45 deletions CHANGELOG.md

This file was deleted.

Loading

0 comments on commit 93446e5

Please sign in to comment.