Skip to content

Commit 7da70aa

Browse files
authored
fix: use short sha for ea versioning (#276)
* fix: use github.run_number Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * chore: use short sha for versioning Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * chore: skip publish on PR Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> --------- Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 15afd53 commit 7da70aa

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
with:
2828
language: javascript
2929
repo-url: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
30-
commit-sha: ${{ github.event.workflow_run && github.event.workflow_run.head_sha || github.event.pull_request.head.sha || github.sha }}
30+
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}

.github/workflows/publish.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
publish-ea:
2323
if: |
2424
github.event_name == 'workflow_run' &&
25-
github.event.workflow_run.head_branch == 'main'
25+
github.event.workflow_run.head_branch == 'main' &&
26+
github.event.workflow_run.event == 'push'
2627
runs-on: ubuntu-latest
2728
name: Publish EA release to NPM
2829
steps:
@@ -58,14 +59,6 @@ jobs:
5859
# Remove both -ea. and -ea- formats for compatibility
5960
BASE_VERSION=$(echo "$VERSION" | sed -E 's/-ea[.-][0-9]+$//')
6061
echo "base-version=$BASE_VERSION" >> "$GITHUB_OUTPUT"
61-
echo "current-version=$VERSION" >> "$GITHUB_OUTPUT"
62-
63-
- name: Update package with EA version
64-
id: bump
65-
run: |
66-
EA_VERSION="${{ steps.current-version.outputs.base-version }}-ea-${{ github.run_number }}"
67-
npm version "$EA_VERSION" --no-git-tag-version
68-
echo "version=$EA_VERSION" >> "$GITHUB_OUTPUT"
6962
7063
- name: Install project modules
7164
run: npm ci
@@ -74,14 +67,14 @@ jobs:
7467
run: npm run compile
7568

7669
- name: Publish package
77-
run: npm publish --verbose --tag ea --access public --provenance
78-
79-
- name: Commit and push package modifications
8070
run: |
81-
git add package.json
82-
git add package-lock.json
83-
git commit -m "build: updated package with ${{ steps.bump.outputs.version }} [skip ci]"
84-
git push
71+
SHORT_SHA=$(git rev-parse --short "${{ github.event.workflow_run.head_sha }}")
72+
EA_VERSION="${{ steps.current-version.outputs.base-version }}-ea.${SHORT_SHA}"
73+
# Temporarily update version for publish
74+
npm version "$EA_VERSION" --no-git-tag-version
75+
npm publish --verbose --tag ea --access public --provenance
76+
# Restore original version
77+
npm version "${{ steps.current-version.outputs.base-version }}" --no-git-tag-version
8578
8679
publish-release:
8780
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trustify-da/trustify-da-javascript-client",
3-
"version": "0.2.4-ea.13",
3+
"version": "0.2.4",
44
"description": "Code-Ready Dependency Analytics JavaScript API.",
55
"license": "Apache-2.0",
66
"homepage": "https://github.com/guacsec/trustify-da-javascript-client#README.md",

0 commit comments

Comments
 (0)