diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8af5ec6..a02ab16 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -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 }} @@ -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 }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..761e101 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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/setup-node@v4.0.0 + 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/setup-node@v4.0.0 + 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/setup-node@v4.0.0 + 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/fvtt-autopublish@v2.0.1 + 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c667cd0..9d1c7ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} @@ -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 }} @@ -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 }} @@ -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 @@ -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 @@ -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 }}