Merge pull request #1620 from phBalance/phBalance/generic-roller-cleanup #333
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
check_release: | |
runs-on: ubuntu-latest | |
if: github.repository == 'dmdorman/hero6e-foundryvtt' | |
outputs: | |
release: ${{ steps.extract_release.outputs.RELEASE }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: Extract version number from system.json | |
id: extract_version | |
run: | | |
VERSION=$(jq -r .version system.json) | |
echo "System version: $VERSION" | |
echo "::set-output name=VERSION::$VERSION" | |
- name: Get the latest release | |
id: latest_release | |
run: | | |
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r .tag_name) | |
echo "Latest release: $LATEST_RELEASE" | |
echo "::set-output name=LATEST_RELEASE::$LATEST_RELEASE" | |
- name: Compare version and release | |
id: extract_release | |
run: | | |
if [[ "${{ steps.extract_version.outputs.VERSION }}" != "${{ steps.latest_release.outputs.LATEST_RELEASE }}" ]]; then | |
RELEASE="${{ steps.extract_version.outputs.VERSION }}" | |
echo "::set-output name=RELEASE::$RELEASE" | |
fi | |
prepare_release: | |
needs: check_release | |
if: (needs.check_release.outputs.release != '') && (github.repository == 'dmdorman/hero6e-foundryvtt') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: build css | |
run: npm ci && npm run compile | |
- name: validate formatting (via prettier) and perform static analysis (via eslint) | |
run: npm run validate | |
- name: Update release version in system.json | |
run: | | |
sed -i 's|"manifest": "[^"]*",|"manifest": "https://github.com/dmdorman/hero6e-foundryvtt/releases/download/${{ needs.check_release.outputs.release }}/system.json",|' system.json | |
sed -i 's|"download": "[^"]*",|"download": "https://github.com/dmdorman/hero6e-foundryvtt/releases/download/${{ needs.check_release.outputs.release }}/hero6efoundryvttv2.zip",|' system.json | |
- name: Make a FoundryVTT system package (manifest and stuff required for execution) and ignore the rest as it is already archived in GitHub and is only needed to build or develop | |
run: | | |
zip -r hero6efoundryvttv2.zip . -x .git/\* -x .github/\* -x node_modules/\* -x scss/\* -x .gitattributes -x .gitignore -x .git-blame-ignore-revs -x .eslintrc.json -x .npmignore -x .prettierignore -x .prettierrc.json -x gulpfile.mjs -x package.json -x package-lock.json | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hero6efoundryvttv2.zip | |
path: hero6efoundryvttv2.zip | |
if-no-files-found: error | |
- name: Create and push tag | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git tag ${{ needs.check_release.outputs.release }} | |
git push origin ${{ needs.check_release.outputs.release }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.check_release.outputs.release }} | |
release_name: Release ${{ needs.check_release.outputs.release }} | |
draft: false | |
prerelease: false | |
- name: Upload system zip | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./hero6efoundryvttv2.zip | |
asset_name: hero6efoundryvttv2.zip | |
asset_content_type: application/zip | |
- name: Upload system.json | |
id: upload-system-json | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./system.json | |
asset_name: system.json | |
asset_content_type: application/json | |
- name: Set RELEASE_NAME environment variable | |
run: echo "RELEASE_NAME=${{ needs.check_release.outputs.release }}" >> $GITHUB_ENV | |
- name: Set MANIFEST_FILE_PATH environment variable | |
run: echo "MANIFEST_FILE_PATH=system.json" >> $GITHUB_ENV | |
outputs: | |
release_name: ${{ needs.check_release.outputs.release }} | |
manifest_file_path: system.json | |
publish_release: | |
needs: prepare_release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Grab manifest file | |
run: wget https://github.com/${{ github.repository }}/releases/download/${{ needs.prepare_release.outputs.release_name }}/system.json | |
- name: Publish to Foundry | |
uses: Varriount/fvtt-autopublish@v2.0.2 | |
with: | |
username: ${{ secrets.FOUNDRY_ADMIN_USERNAME }} | |
password: ${{ secrets.FOUNDRY_ADMIN_PASSWORD }} | |
module-id: ${{ secrets.MODULE_ID }} | |
manifest-url: https://github.com/${{ github.repository }}/releases/download/${{ needs.prepare_release.outputs.release_name }}/system.json | |
manifest-file: ${{ needs.prepare_release.outputs.manifest_file_path }} |