Skip to content

Commit ad213de

Browse files
committed
test
1 parent b5a8113 commit ad213de

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

.github/workflows/repo.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -78,38 +78,38 @@ jobs:
7878
cmd: test
7979

8080
publish:
81-
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize') }}
81+
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize')
8282
runs-on: ubuntu-latest
8383
steps:
84-
- uses: actions/checkout@v2
85-
84+
- uses: actions/checkout@v3
85+
with:
86+
fetch-depth: 0 # Fetch all history for all branches and tags
87+
8688
- name: Set up Node.js ${{ env.NODE_VERSION }}
8789
uses: actions/setup-node@v3
8890
with:
8991
node-version: ${{ env.NODE_VERSION }}
9092
cache: 'npm'
91-
93+
9294
- name: Restore node modules from cache
9395
uses: actions/cache@v3
9496
with:
9597
path: node_modules
9698
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
9799
restore-keys: |
98100
${{ runner.os }}-node-
99-
101+
100102
- name: Prepare version for publish
101-
id: prep
102103
run: |
103104
PR_NUMBER=$(echo ${{ github.event.number }})
104105
CURRENT_VERSION=$(node -p "require('./package.json').version")
105-
# Fetch all history for all tags and branches to ensure we're counting accurately
106-
git fetch --prune --unshallow
107-
# Count the number of commits on the current branch and subtract 1 to start the index at 0
106+
# Ensure we have the full history to accurately count commits
107+
git fetch --prune --unshallow || git fetch --depth=1 origin master:refs/remotes/origin/master
108+
# Count the number of commits on the current branch
108109
COMMIT_COUNT=$(($(git log master..HEAD --oneline | wc -l) - 1))
109110
NEW_VERSION="${CURRENT_VERSION}-dev.${PR_NUMBER}.${COMMIT_COUNT}"
110111
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
111-
112+
112113
- name: Echo version for testing
113114
run: |
114-
echo "Version to publish: $NEW_VERSION"
115-
echo "Adds a commit to test increment"
115+
echo "Version to publish: $NEW_VERSION"

0 commit comments

Comments
 (0)