Build and Minify Library #24
Workflow file for this run
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: Build and Minify Library | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
release: | |
types: | |
- created | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20.x" | |
- name: Install dependencies | |
run: npm install | |
- name: Build and minify | |
run: npm run build | |
- name: Archive dist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: g-calendar-fetcher-minified | |
path: dist/g-calendar-fetcher.min.js | |
- name: Commit dist files to main | |
if: startsWith(github.event.ref, 'refs/tags/v') # Only run for version tags | |
run: | | |
git config --local user.name "GitHub Actions" | |
git config --local user.email "actions@github.com" | |
git add dist/g-calendar-fetcher.min.js | |
git commit -m "Add minified file for version ${{ github.ref_name }}" | |
git fetch origin main # Ensure the main branch is up-to-date | |
git checkout main # Checkout the main branch | |
git pull origin main # Pull latest changes | |
git push origin main # Push changes to main | |
- name: Create Release | |
if: startsWith(github.event.ref, 'refs/tags/v') # Only run for tags | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
body: | | |
Release of version ${{ github.ref_name }} | |
## Breaking changes | |
- **[v0.4.0]** Events are now sorted the other way around. Future events are now at the top. | |
- name: Upload Minified Library to Release | |
if: startsWith(github.event.ref, 'refs/tags/v') # Only run for tags | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: dist/g-calendar-fetcher.min.js | |
asset_name: g-calendar-fetcher.min.js | |
asset_content_type: application/javascript |