Skip to content

Commit 62d3184

Browse files
committed
chore: refactor workflows
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent ea76472 commit 62d3184

8 files changed

Lines changed: 254 additions & 368 deletions

File tree

.github/workflows/integration.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
22
---
3-
name: Integration
3+
name: Integration Tests
44

55
on:
6+
workflow_run:
7+
workflows: ["Test"]
8+
types:
9+
- completed
610
workflow_dispatch:
711
pull_request:
812
branches:
@@ -14,8 +18,13 @@ concurrency:
1418

1519
jobs:
1620
call-shared:
21+
# Only run if the test workflow succeeded, or if triggered directly
22+
if: |
23+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') ||
24+
github.event_name == 'workflow_dispatch' ||
25+
github.event_name == 'pull_request'
1726
uses: trustification/exhort-integration-tests/.github/workflows/integration.yml@main
1827
with:
1928
language: javascript
2029
repo-url: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
21-
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}
30+
commit-sha: ${{ github.event.workflow_run.head_sha || github.event.pull_request.head.sha || github.sha }}

.github/workflows/publish-prerelease.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

.github/workflows/publish-release.yml

Lines changed: 0 additions & 112 deletions
This file was deleted.

.github/workflows/publish-switch.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
2+
---
3+
name: Publish
4+
5+
on:
6+
workflow_run:
7+
workflows: ["Integration Tests"]
8+
types:
9+
- completed
10+
branches:
11+
- main
12+
push:
13+
tags:
14+
- 'v*.*.*'
15+
- '*.*.*'
16+
17+
permissions:
18+
contents: write
19+
id-token: write
20+
21+
jobs:
22+
publish-ea:
23+
if: |
24+
github.event_name == 'workflow_run' &&
25+
github.event.workflow_run.head_branch == 'main'
26+
runs-on: ubuntu-latest
27+
name: Publish EA release to NPM
28+
steps:
29+
- name: Checkout sources
30+
uses: actions/checkout@v4
31+
with:
32+
ref: ${{ github.event.workflow_run.head_sha }}
33+
fetch-depth: 0
34+
35+
- name: Install node 24
36+
uses: actions/setup-node@v5
37+
with:
38+
node-version: 24
39+
cache: npm
40+
registry-url: 'https://registry.npmjs.org'
41+
42+
- name: Update npm
43+
run: npm install -g npm@latest
44+
45+
- name: Configure git
46+
run: |
47+
git config user.name "${{ github.actor }}"
48+
git config user.email "${{ github.actor }}@users.noreply.github.com"
49+
50+
- name: Get current version
51+
id: current-version
52+
run: |
53+
VERSION=$(node -p "require('./package.json').version")
54+
# Remove both -ea. and -ea- formats for compatibility
55+
BASE_VERSION=$(echo "$VERSION" | sed -E 's/-ea[.-][0-9]+$//')
56+
echo "base-version=$BASE_VERSION" >> "$GITHUB_OUTPUT"
57+
echo "current-version=$VERSION" >> "$GITHUB_OUTPUT"
58+
59+
- name: Update package with EA version
60+
id: bump
61+
run: |
62+
EA_VERSION="${{ steps.current-version.outputs.base-version }}-ea-${{ github.run_number }}"
63+
npm version "$EA_VERSION" --no-git-tag-version
64+
echo "version=$EA_VERSION" >> "$GITHUB_OUTPUT"
65+
66+
- name: Install project modules
67+
run: npm ci
68+
69+
- name: Compile project
70+
run: npm run compile
71+
72+
- name: Publish package
73+
run: npm publish --verbose --tag ea --access public --provenance
74+
75+
- name: Commit and push package modifications
76+
run: |
77+
git add package.json
78+
git add package-lock.json
79+
git commit -m "build: updated package with ${{ steps.bump.outputs.version }} [skip ci]"
80+
git push
81+
82+
- name: Create and push new tag
83+
run: |
84+
git tag ${{ steps.bump.outputs.version }} -m "${{ steps.bump.outputs.version }}"
85+
git push origin ${{ steps.bump.outputs.version }}
86+
87+
publish-release:
88+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
89+
runs-on: ubuntu-latest
90+
name: Publish release to NPM
91+
steps:
92+
- name: Checkout sources
93+
uses: actions/checkout@v4
94+
with:
95+
ref: ${{ github.ref }}
96+
fetch-depth: 0
97+
98+
- name: Install node 24
99+
uses: actions/setup-node@v5
100+
with:
101+
node-version: 24
102+
cache: npm
103+
registry-url: 'https://registry.npmjs.org'
104+
105+
- name: Update npm
106+
run: npm install -g npm@latest
107+
108+
- name: Get tag name
109+
id: tag
110+
run: |
111+
TAG_NAME=${GITHUB_REF#refs/tags/}
112+
echo "name=$TAG_NAME" >> "$GITHUB_OUTPUT"
113+
114+
- name: Update package.json with tag version
115+
id: update-version
116+
run: |
117+
TAG_NAME="${{ steps.tag.outputs.name }}"
118+
# Remove 'v' prefix if present
119+
VERSION=${TAG_NAME#v}
120+
npm version "$VERSION" --no-git-tag-version
121+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
122+
123+
- name: Install project modules
124+
run: npm ci
125+
126+
- name: Compile project
127+
run: npm run compile
128+
129+
- name: Publish package
130+
run: npm publish --verbose --access public --provenance

0 commit comments

Comments
 (0)