bump version for new terminal structure #11
This file contains hidden or 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: Tag or Deploy | |
| on: | |
| push: | |
| # a push to main updating package.json will check if a new tag is needed | |
| branches: ["main"] | |
| paths: ["package.json"] | |
| # a push of a tag will trigger a deployment | |
| tags: ["v*"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine Release Mode | |
| id: mode | |
| run: | | |
| # CASE 1: Manual Trigger via Workflow Dispatch | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "ℹ️ Manual trigger detected. Deploying current state." | |
| echo "do_deploy=true" >> $GITHUB_OUTPUT | |
| echo "do_tag=false" >> $GITHUB_OUTPUT | |
| echo "tag_name=manual-$(date +%s)" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # CASE 2: Pushed a Tag (Standard Manual Release) | |
| if [[ "${{ github.ref_type }}" == "tag" ]]; then | |
| echo "ℹ️ Triggered by tag: ${{ github.ref_name }}" | |
| echo "do_deploy=true" >> $GITHUB_OUTPUT | |
| echo "do_tag=false" >> $GITHUB_OUTPUT | |
| echo "tag_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # CASE 3: Pushed to Main (Check for Version Bump) | |
| VERSION=$(jq -r .version package.json) | |
| TAG="v$VERSION" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| # Tag exists -> Version wasn't bumped -> DO NOT DEPLOY | |
| echo "⚠️ Tag $TAG already exists. Version was not changed. Skipping." | |
| echo "do_deploy=false" >> $GITHUB_OUTPUT | |
| echo "do_tag=false" >> $GITHUB_OUTPUT | |
| else | |
| # Tag missing -> Version was bumped -> AUTO RELEASE | |
| echo "🚀 New version $VERSION detected. Starting auto-release." | |
| echo "do_deploy=true" >> $GITHUB_OUTPUT | |
| echo "do_tag=true" >> $GITHUB_OUTPUT | |
| echo "tag_name=$TAG" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Node | |
| if: steps.mode.outputs.do_deploy == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| if: steps.mode.outputs.do_deploy == 'true' | |
| run: npm ci | |
| - name: Build Project | |
| if: steps.mode.outputs.do_deploy == 'true' | |
| run: | | |
| npm run clean | |
| npm run bundle | |
| npm run generate-licenses | |
| npm run build:docs | |
| - name: Prepare Artifacts | |
| if: steps.mode.outputs.do_deploy == 'true' | |
| run: | | |
| mkdir dist | |
| cp index.html dist/ | |
| cp -r fsedit dist/ | |
| cp -r recover_fs dist/ | |
| cp -r docs dist/ | |
| cp -r public dist/ | |
| cp CNAME dist/ || true | |
| cp _config.yml dist/ || true | |
| cp robots.txt dist/ || true | |
| cp LICENSE dist/ || true | |
| cp .nojekyll dist/ || true | |
| - name: Deploy to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: gh-pages | |
| folder: dist | |
| clean: true | |
| git-config-email: "github-actions[bot]@users.noreply.github.com" | |
| git-config-name: "github-actions[bot]" | |
| # ONLY runs if we are in "Auto Mode" (Branch push), NOT manual tag mode | |
| - name: Auto-Create Git Tag | |
| if: steps.mode.outputs.do_tag == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| TAG="${{ steps.mode.outputs.tag_name }}" | |
| git tag -a "$TAG" -m "Auto-release $TAG" | |
| git push origin "$TAG" |