Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Finding Base Tag 'last-release' During GitHub Action Execution #845

Open
mohijalili opened this issue Jul 23, 2024 · 3 comments
Open

Comments

@mohijalili
Copy link

Description

I am encountering an issue when running the semver for the first time and subsequently when triggered by GitHub Actions. Initially, I receive the following message:

[lib1] 🟠 No previous version tag found, fallback to version 0.0.0.
New version will be calculated based on all changes since first commit.
If your project is already versioned, please tag the latest release commit with lib1_x.y.z and run this command again.

After removing the tags and running the action again, I encounter this error:

Run npx nx affected --base=last-release --target=version --baseBranch=main --trackDeps=true --allowEmptyRelease=true --dry-run=true

fatal: ambiguous argument 'last-release': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
nx affected
Run target for affected projects
...
Error: Command failed: git diff --name-only --no-renames --relative "last-release" "HEAD"
fatal: ambiguous argument 'last-release': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
...

GitHub Action Configuration

Below is the configuration of my GitHub Action for semantic release:

name: Semantic Release

on:
  push:
    branches: ['main']
  workflow_dispatch:

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Use Node.js
        uses: actions/[email protected]
        with:
          node-version: 18.10.0
      - name: Setup Git
        run: |
          git config --global user.email ${{ secrets }}
          git config --global user.name ${{secrets }}
          git config --global credential.helper store
      - run: npm ci
      - name: Version
        shell: bash
        run: npx nx affected --base=last-release --target=version --baseBranch=main --trackDeps=true --allowEmptyRelease=true --dry-run=true
      - name: Tag last-release
        shell: bash
        run: |
          git tag -f last-release
          echo "https://${{ secrets }}:${{ secrets }}@github.com/${{ github.repository }}.git" > .git/credentials
          git push origin last-release --force

Each project has the following config:

    "version": {
      "executor": "@jscutlery/semver:version",
      "options": {
        "preset": "angular",
        "baseBranch": "HEAD:main",
        "tagPrefix": "lib1_",
        "push": true,
        "trackDeps": true,
        "commitMessageFormat": "feat({projectName}): release version {version} [skip ci]"
      }
    }

Additional Context

  • Node.js version: 18.10.0
  • "@nx/storybook": "16.10.0"
  • "@jscutlery/semver": "^5.2.2",
@mohijalili
Copy link
Author

Hey @edbzn , Can you help me out?

@christiankaseburg
Copy link

christiankaseburg commented Aug 1, 2024

Hey, @mohijalili have you tried creating a light weight “last-release” tag based on a specific commit and pushing it from your local to your remote before running your workflow?

For example, create a tag based off the commit you want to start from on your local “git tag last-release COMMIT_HASH”. Then, push it to your remote “git push origin last-release” and start your release on GitHub.

Side note, you should remove the baseBranch, allowEmptyRelease, and dry-run flags from your version job in your workflow before running if you want to create a release.

@mohijalili
Copy link
Author

Hey, @mohijalili have you tried creating a light weight “last-release” tag based on a specific commit and pushing it from your local to your remote before running your workflow?

For example, create a tag based off the commit you want to start from on your local “git tag last-release COMMIT_HASH”. Then, push it to your remote “git push origin last-release” and start your release on GitHub.

Side note, you should remove the baseBranch, allowEmptyRelease, and dry-run flags from your version job in your workflow before running if you want to create a release.

@christiankaseburg Yeah, I tried it and, like you said, I ran into two different errors while setting up semver. (you can find it in the initial description) Can you explain why I should remove baseBranch, allowEmptyRelease, and dry-run?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants