Skip to content

Commit 608d9f3

Browse files
ErioldDaniel Montoya
andauthored
fix(): se detecta la version en produccion de github actions (#669)
Co-authored-by: Daniel Montoya <daniel.montoya@eclass.cl>
1 parent b26d7fb commit 608d9f3

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

.github/workflows/nodejs.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: webfactory/ssh-agent@v0.7.0
1818
with:
1919
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
20-
- name: Add Know Hosts
20+
- name: Add Known Hosts
2121
run: |
2222
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
2323
shell: bash
@@ -31,10 +31,13 @@ jobs:
3131
run: npm run lint:check
3232
- name: Testing JEST
3333
run: npm run test
34+
3435
release:
3536
if: github.ref == 'refs/heads/main'
3637
needs: test
3738
runs-on: ubuntu-latest
39+
outputs:
40+
new_version: ${{ steps.get_version.outputs.VERSION }}
3841
steps:
3942
- uses: actions/checkout@v4
4043
- uses: actions/setup-node@v4
@@ -44,7 +47,7 @@ jobs:
4447
- uses: webfactory/ssh-agent@v0.7.0
4548
with:
4649
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
47-
- name: Add Know Hosts
50+
- name: Add Known Hosts
4851
run: |
4952
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
5053
shell: bash
@@ -54,14 +57,17 @@ jobs:
5457
run: rm -rf node_modules
5558
- name: Clean install on CI
5659
run: npm ci
57-
- name: Build library
58-
run: npm run build
5960
- name: Release version
61+
id: semantic_release
6062
run: npx semantic-release@18
6163
env:
6264
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6365
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6466

67+
- name: Get new version
68+
id: get_version
69+
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
70+
6571
build-pages:
6672
name: Build to GitHub Pages
6773
needs: release
@@ -81,7 +87,7 @@ jobs:
8187
- uses: webfactory/ssh-agent@v0.7.0
8288
with:
8389
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
84-
- name: Add Know Hosts
90+
- name: Add Known Hosts
8591
run: |
8692
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
8793
shell: bash
@@ -91,8 +97,10 @@ jobs:
9197
run: rm -rf node_modules
9298
- name: Clean install on CI
9399
run: npm ci
100+
94101
- name: Generate new Build to Pages
95-
run: npm run deploy
102+
run: VITE_APP_VERSION=${{ needs.release.outputs.new_version }} npm run deploy
103+
96104
- name: Upload deploy-ready build files
97105
uses: actions/upload-artifact@v4
98106
with:
@@ -118,7 +126,7 @@ jobs:
118126
- uses: webfactory/ssh-agent@v0.7.0
119127
with:
120128
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
121-
- name: Add Know Hosts
129+
- name: Add Known Hosts
122130
run: |
123131
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
124132
shell: bash
@@ -129,4 +137,4 @@ jobs:
129137
GH_TOKEN: eclass:${{ secrets.GITHUB_TOKEN }}
130138
with:
131139
github_token: ${{ secrets.GITHUB_TOKEN }}
132-
publish_dir: ./dist
140+
publish_dir: ./dist

vite.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
33
import tsconfigPaths from 'vite-tsconfig-paths'
44
import path from 'path'
5-
import { version } from './package.json'
65

76
// https://vitejs.dev/config/
87

@@ -17,14 +16,14 @@ if (buildEnv === 'DOCUMENTATION') {
1716
sourcemap: true,
1817
},
1918
define : {
20-
_APP_VERSION_: JSON.stringify(version),
19+
_APP_VERSION_: JSON.stringify(process.env.VITE_APP_VERSION || 'desarrollo'),
2120
}
2221
}
2322
} else {
2423
myDefineConfig = {
2524
plugins: [react(), tsconfigPaths()],
2625
define : {
27-
_APP_VERSION_: JSON.stringify(version),
26+
_APP_VERSION_: JSON.stringify(process.env.VITE_APP_VERSION || 'desarrollo'),
2827
},
2928
build: {
3029
lib: {

0 commit comments

Comments
 (0)