mirror of
https://github.com/SwingTheVine/Wplace-BlueMarble.git
synced 2026-03-11 21:26:55 +00:00
78 lines
2.5 KiB
YAML
78 lines
2.5 KiB
YAML
name: Bump, Build, Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
|
|
# Builds the code
|
|
# This is bundling, obfuscating, version bumping, etc.
|
|
build:
|
|
permissions:
|
|
contents: write
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Install dependencies
|
|
run: npm install
|
|
|
|
- name: Update userscript version
|
|
run: |
|
|
npm version minor --no-git-tag-version
|
|
node build/update-version.js
|
|
|
|
- name: Build userscript
|
|
run: npm run build
|
|
|
|
- name: Get current version
|
|
id: get_version
|
|
run: |
|
|
current_version=$(jq -r '.version' package.json)
|
|
echo "Current version: $current_version"
|
|
echo "current_version=$current_version" >> $GITHUB_OUTPUT
|
|
|
|
- name: Update static version numbers
|
|
run: |
|
|
current_version=${{ steps.get_version.outputs.current_version }}
|
|
if [ -f "docs/README.md" ]; then
|
|
echo "README.md exists. Modifying..."
|
|
else
|
|
echo "README.md was not found. Skipping..."
|
|
fi
|
|
sed -i 's|\(Latest_Version-\)[^-\ ]*\(-lightblue\)|\1'$current_version'\2|' docs/README.md
|
|
|
|
- name: Update compression badge
|
|
run: |
|
|
dist_size=$(find dist -type f -exec cat {} + | wc -c)
|
|
src_size=$(find src dist/assets -type f -exec cat {} + | wc -c)
|
|
percentage=$(awk "BEGIN {printf \"%.2f\", 100 - ($dist_size * 100) / $src_size}")
|
|
echo "Compression: $percentage"
|
|
badge_url="https://img.shields.io/badge/Compression-${percentage}%25-blue"
|
|
sed -i -E 's#https://img.shields.io/badge/Compression-[^"]*#'"$badge_url"'#' docs/README.md
|
|
|
|
- name: Get the previous commit message
|
|
id: get-commit-message
|
|
run: echo "MSG=$(git log -1 --pretty=%B)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Commit and push built script
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
|
git add dist/*
|
|
git add src/BlueMarble.meta.js
|
|
git add package.json
|
|
git add docs/README.md
|
|
git commit -m "Bumped version; ${{ steps.get-commit-message.outputs.MSG }}" || echo "No changes to commit"
|
|
git push
|