Merge pull request #17 from jamiefdhurst/tests #3
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 | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| paths: | |
| - '*.css' | |
| - '*.js' | |
| - '*.mjs' | |
| - '*.json' | |
| - '*.ts' | |
| - '*.md' | |
| - 'docs/**' | |
| - 'src/**' | |
| permissions: | |
| contents: write | |
| jobs: | |
| Build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT }} | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| run: | | |
| npm i | |
| - name: Get Latest Version | |
| id: latest | |
| uses: gregziegan/[email protected] | |
| continue-on-error: true | |
| - name: Calculate Next Version | |
| id: calculate | |
| uses: paulhatch/[email protected] | |
| with: | |
| debug: true | |
| tag_prefix: "" | |
| version_format: "${major}.${minor}.${patch}" | |
| - name: Determine Next Version | |
| id: version | |
| uses: haya14busa/action-cond@v1 | |
| with: | |
| cond: ${{ contains(steps.latest.outputs.name, '.') }} | |
| if_true: ${{ steps.calculate.outputs.version }} | |
| if_false: '0.0.1' | |
| - name: Remove Leading "v" from Latest Version | |
| if: ${{ contains(steps.latest.outputs.name, '.') }} | |
| id: latest_clean | |
| run: | | |
| export version=$(echo ${{ steps.latest.outputs.name }} | sed 's/^v//') | |
| echo ::set-output name=name::$version | |
| - name: Update Version in Files | |
| if: ${{ contains(steps.latest.outputs.name, '.') }} | |
| uses: datamonsters/replace-action@v2 | |
| with: | |
| files: 'package.json' | |
| replacements: "${{ steps.latest_clean.outputs.name }}=${{ steps.version.outputs.value }}" | |
| - name: Update Version Script | |
| if: ${{ contains(steps.latest.outputs.name, '.') }} | |
| run: VERSION=${{ steps.version.outputs.value }} npm run version | |
| - name: File Save Delay | |
| uses: jakejarvis/wait-action@master | |
| with: | |
| time: '2s' | |
| - name: Commit Version Changes | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "[skip ci] Update version to v${{ steps.version.outputs.value }}" | |
| - name: Build | |
| run: npm run build | |
| - name: Create Release | |
| uses: ncipollo/[email protected] | |
| with: | |
| allowUpdates: true | |
| artifacts: 'main.js,manifest.json,styles.css' | |
| draft: false | |
| makeLatest: true | |
| tag: ${{ steps.version.outputs.value }} | |
| name: ${{ steps.version.outputs.value }} |