update version #530
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: validate | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| jobs: | |
| validate: | |
| name: Validate on Node ${{ matrix.node }} / ${{ matrix.os }} / ${{ matrix.storage-engine }} | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'pull_request' | |
| strategy: | |
| matrix: | |
| node: ["20.x", "22.x", "24.x"] | |
| os: [ubuntu-latest, windows-latest, macOS-latest] | |
| storage-engine: [in-memory, sqlite] | |
| exclude: | |
| - node: "20.x" | |
| storage-engine: sqlite | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| CI: true | |
| STORAGE_ENGINE: ${{ matrix.storage-engine }} | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| - name: Set up Node.js | |
| uses: labd/gh-actions-typescript/pnpm-install@e7a21fb56b52bf2d91616e34f0bc3f4f9a821b62 # main | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: Check formatting and typing | |
| run: pnpm check | |
| - name: Run tests | |
| run: pnpm test:ci | |
| - name: Run build | |
| run: pnpm build | |
| release: | |
| timeout-minutes: 15 | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event.pull_request.draft == false | |
| permissions: | |
| id-token: write | |
| contents: write | |
| pull-requests: write | |
| environment: release | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| needs: validate | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| - name: Set up Node.js | |
| uses: labd/gh-actions-typescript/pnpm-install@e7a21fb56b52bf2d91616e34f0bc3f4f9a821b62 # main | |
| - name: Run build | |
| run: pnpm build | |
| - name: Upgrade npm for trusted publishing | |
| run: npm i -g npm@^11.6.4 | |
| - name: Create and publish versions | |
| uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1.7.0 | |
| id: changesets | |
| with: | |
| title: "Release new version" | |
| commit: "update version" | |
| publish: pnpm publish:ci | |
| version: pnpm publish:version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_CONFIG_PROVENANCE: true | |
| docker: | |
| name: Publish Docker Image | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: needs.release.outputs.published == 'true' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Resolve newest release tag | |
| id: latest_tag | |
| shell: bash | |
| run: | | |
| TAG="$(git tag --points-at HEAD --sort=-v:refname | head -n 1)" | |
| if [ -z "$TAG" ]; then | |
| TAG="$(git tag --sort=-creatordate | head -n 1)" | |
| fi | |
| if [ -z "$TAG" ]; then | |
| echo "No git tags found after release" >&2 | |
| exit 1 | |
| fi | |
| echo "value=$TAG" >> "$GITHUB_OUTPUT" | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 | |
| with: | |
| images: labdigital/commercetools-mock-server | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ steps.latest_tag.outputs.value }} | |
| type=raw,value=latest,enable=${{ !contains(steps.latest_tag.outputs.value, 'beta') }} | |
| - name: Build and push | |
| uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 | |
| with: | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |