Fixed test file #24
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history to resolve conflicts properly | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Reset Git working directory | |
| run: | | |
| git reset --hard | |
| git clean -fdx | |
| - name: Install dependencies | |
| run: npm ci --include=dev | |
| - name: Run tests | |
| run: npm test | |
| - name: Build project | |
| run: npm run build | |
| release: | |
| needs: build # Runs only after build job succeeds | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: "https://registry.npmjs.org/" | |
| always-auth: true | |
| - name: Reset Git working directory | |
| run: | | |
| git reset --hard | |
| git clean -fdx | |
| - name: Install dependencies | |
| run: npm ci --include=dev | |
| - name: Install rollup | |
| run: npm install rollup | |
| - name: Build project | |
| run: npm run build | |
| - name: Bump version automatically | |
| id: version | |
| run: | | |
| # Set the Git configuration with the username of the person who triggered the action | |
| git config --global user.name "${{ github.actor }}" | |
| git config --global user.email "${{ github.actor }}@users.noreply.github.com" | |
| # Ensure the working directory is clean | |
| git status | |
| git reset --hard | |
| git clean -fdx | |
| # Get current version and bump it | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| NEW_VERSION=$(npm version patch -m "Bump version to %s") | |
| echo "VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
| # Ensure the working directory is clean again | |
| git status | |
| git add -A || echo "No changes to commit" | |
| git commit -m "Auto commit changes for version bump" || echo "No changes to commit" | |
| # Push changes and tags | |
| git push origin main --tags | |
| - name: Ensure Rollup is available | |
| run: npx rollup --version | |
| - name: Reinstall dependencies | |
| run: npm ci | |
| - name: Publish to npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access public | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag_name: ${{ env.VERSION }} | |
| name: "Release ${{ env.VERSION }}" | |
| body: "New release of Base64Plus!" | |
| draft: false | |
| prerelease: false | |
| files: | | |
| dist/base64Plus.umd.js | |
| dist/base64Plus.esm.js | |
| dist/base64Plus.iife.js |