bug fix + packages version updates #15
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: Build and Release | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "src/**" | |
| - "webpack.config.mjs" | |
| - "package.json" | |
| - ".github/workflows/**" | |
| pull_request: | |
| paths: | |
| - "src/**" | |
| - "webpack.config.mjs" | |
| - "package.json" | |
| - ".github/workflows/**" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the code | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # Step 2: Set up Node.js using .nvmrc | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version-file: .nvmrc | |
| # Step 3: Install dependencies | |
| - name: Install dependencies | |
| run: npm install | |
| # Step 4: Build the project | |
| - name: Build project | |
| run: npm run build | |
| # Step 4.5: Extract version from package.json | |
| - name: Get Package Version | |
| id: pkg_version | |
| run: | | |
| VERSION=$(jq -r '.version' package.json) | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| # Step 5: Create a GitHub Release | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.pkg_version.outputs.VERSION }} | |
| release_name: Release v${{ steps.pkg_version.outputs.VERSION }} | |
| draft: false | |
| prerelease: false | |
| # Step 6: Archive each folder within dist and upload each as a release asset | |
| - name: Archive and Upload Release Assets | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| UPLOAD_URL="${{ steps.create_release.outputs.upload_url }}" | |
| UPLOAD_URL="${UPLOAD_URL%\{*}" | |
| for folder in dist/*/; do | |
| folder=${folder%/} # Remove trailing slash | |
| zip_name="${folder##*/}.zip" | |
| echo "Zipping contents of $folder into $zip_name" | |
| pushd "$folder" > /dev/null | |
| zip -r "$GITHUB_WORKSPACE/$zip_name" ./* | |
| popd > /dev/null | |
| echo "Uploading $zip_name" | |
| curl -s --data-binary @"$GITHUB_WORKSPACE/$zip_name" \ | |
| -H "Content-Type: application/zip" \ | |
| -H "Authorization: token ${GITHUB_TOKEN}" \ | |
| "$UPLOAD_URL?name=$(basename "$zip_name")" | |
| done |