fix: Order of plugins, so it commits the package.json #101
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: Release | |
| on: | |
| workflow_run: | |
| workflows: [ Test ] | |
| branches: [ main ] | |
| types: | |
| - completed | |
| push: | |
| branches: [ next, prerelease ] | |
| # This part sets up the Trusted Publishers for npm via GitHub Actions, | |
| # that's why we don't need to set up the token manually | |
| permissions: | |
| id-token: write | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| release: | |
| if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm | |
| key: cache-node-modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build the CLI | |
| run: npm run build | |
| - name: Store version before release | |
| id: version-before | |
| run: echo "VERSION=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT" | |
| - name: Run npm release | |
| run: npm run release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GIT_AUTHOR_NAME: Tolgee Machine | |
| GIT_AUTHOR_EMAIL: machine@tolgee.io | |
| GIT_COMMITTER_NAME: Tolgee Machine | |
| GIT_COMMITTER_EMAIL: machine@tolgee.io | |
| - name: Extract version after release | |
| id: version-after | |
| run: echo "VERSION=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT" | |
| - name: Check if version was released | |
| id: version-check | |
| run: | | |
| if [ "${{ steps.version-before.outputs.VERSION }}" != "${{ steps.version-after.outputs.VERSION }}" ]; then | |
| echo "RELEASED=true" >> "$GITHUB_OUTPUT" | |
| echo "New version released: ${{ steps.version-before.outputs.VERSION }} -> ${{ steps.version-after.outputs.VERSION }}" | |
| else | |
| echo "RELEASED=false" >> "$GITHUB_OUTPUT" | |
| echo "No new version released (version remains ${{ steps.version-before.outputs.VERSION }})" | |
| fi | |
| - name: Build and push Docker image | |
| if: steps.version-check.outputs.RELEASED == 'true' | |
| run: ./scripts/build-docker.sh latest linux/amd64,linux/arm64 push | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| VERSION: ${{ steps.version-after.outputs.VERSION }} | |
| GITHUB_SHA: ${{ github.event.workflow_run.head_sha || github.sha }} | |
| BUILD_DATE: ${{ github.event.workflow_run.run_started_at || github.event.workflow_run.head_commit.timestamp }} |