Skip to content

matches not found in google action #164

@shaunc

Description

@shaunc

I am trying to use semantic-release-replace-plugin to change version in pyproject.toml and src/demo/__init__.py In the first I have:

[tool.poetry]
...
version = "0.1.5"

In the second:

__version__ = "0.1.5"

My semantic-release config:

branches:
  - main
  - {name: alpha, prerelease: true}
  - {name: beta, prerelease: true}
plugins:
  - "@semantic-release/commit-analyzer"
  - "@semantic-release/release-notes-generator"
  - - "@google/semantic-release-replace-plugin"
    - replacements:
      - files:
        - pyproject.toml
        from: 'version = ".*"'
        to: 'version = "${nextRelease.version}"'
        results:
          - file: pyproject.toml
            hasChanged: true
            numMatches: 1
            numReplacements: 1
        countMatches: true
      - files:
        - src/demo/__init__.py
        from: '__VERSION__ = ".*"'
        to: '__VERSION__ = "${nextRelease.version}"'
        results:
          - file: src/demo/__init__.py
            hasChanged: true
            numMatches: 1
            numReplacements: 1
        countMatches: true
  - - "@semantic-release/git"
    - assets:
      - pyproject.toml
      - src/demo/*.py
  - "@semantic-release/github"

I run using:

  Release:
    needs: Quality
    runs-on: ubuntu-latest
    concurrency: release
    # https://github.community/t/how-do-i-specify-job-dependency-running-in-another-workflow/16482
    if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):')

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 14
      - name: Install semantic-release
        run: npm install -g semantic-release @semantic-release/github @semantic-release/commit-analyzer @semantic-release/git @semantic-release/release-notes-generator "@google/semantic-release-replace-plugin"
        # semantic-release-pypi
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.9
      - name: Install setuptools
        run: python -m pip install --upgrade setuptools wheel twine
      - name: Release
        env:
          GITHUB_TOKEN: ${{ github.token }}
          # PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
        run: npx semantic-release

This gives me the error below. It would seem that "expected" is no matches, but actual results in match. However, I specify that I do expect a match. (??) Also why does the error message read "expected match not found" when the detail is consistent with "unexpected match found"?

[5:17:45 PM] [semantic-release] › ✖  An error occurred while running semantic-release: Error: Expected match not found!
- Expected
+ Received

  Array [
    Object {
-     "file": "src/demo/__init__.py",
-     "hasChanged": false,
-     "numMatches": 0,
-     "numReplacements": 0,
+     "file": "demo/__init__.py",
+     "hasChanged": true,
+     "numMatches": 1,
+     "numReplacements": 1,
    },
  ]
    at /opt/hostedtoolcache/node/14.19.0/x64/lib/node_modules/@google/semantic-release-replace-plugin/dist/index.js:98:35
    at step (/opt/hostedtoolcache/node/14.19.0/x64/lib/node_modules/@google/semantic-release-replace-plugin/dist/index.js:59:23)
    at Object.next (/opt/hostedtoolcache/node/14.19.0/x64/lib/node_modules/@google/semantic-release-replace-plugin/dist/index.js:40:53)
    at fulfilled (/opt/hostedtoolcache/node/14.19.0/x64/lib/node_modules/@google/semantic-release-replace-plugin/dist/index.js:31:58) {
  pluginName: '@google/semantic-release-replace-plugin'
}
Error: Expected match not found!
- Expected
+ Received

  Array [
    Object {
-     "file": "src/demo/__init__.py",
-     "hasChanged": false,
-     "numMatches": 0,
-     "numReplacements": 0,
+     "file": "demo/__init__.py",
+     "hasChanged": true,
+     "numMatches": 1,
+     "numReplacements": 1,
    },
  ]
    at /opt/hostedtoolcache/node/14.19.0/x64/lib/node_modules/@google/semantic-release-replace-plugin/dist/index.js:98:35
    at step (/opt/hostedtoolcache/node/14.19.0/x64/lib/node_modules/@google/semantic-release-replace-plugin/dist/index.js:59:23)
    at Object.next (/opt/hostedtoolcache/node/14.19.0/x64/lib/node_modules/@google/semantic-release-replace-plugin/dist/index.js:40:53)
    at fulfilled (/opt/hostedtoolcache/node/14.19.0/x64/lib/node_modules/@google/semantic-release-replace-plugin/dist/index.js:31:58) {
  pluginName: '@google/semantic-release-replace-plugin'
}
Error: Process completed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions