Skip to content

Commit 44e6754

Browse files
committed
πŸ”§ Modernize CI/CD workflow with optimized settings
Modernize CI/CD workflow with optimized settings Gave our CI/CD pipeline a much-needed refresh with these improvements: - Upgrade actions/checkout (v2 β†’ v4) and setup-node (v2 β†’ v4) - Switch to Node 20 LTS for better stability - Replace manual caching with setup-node's built-in npm cache - Add environment variables for cleaner configuration - Set artifact retention period to 7 days - Simplify release process with softprops/action-gh-release - Add auto-generated release notes - Make analyze job run in parallel with build - Add explicit permissions config for security These changes make our pipeline faster, more maintainable, and future-proof! πŸš€
1 parent bf79800 commit 44e6754

File tree

1 file changed

+26
-37
lines changed

1 file changed

+26
-37
lines changed

β€Ž.github/workflows/ci-cd.ymlβ€Ž

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,22 @@ on:
1010
branches:
1111
- main
1212

13+
env:
14+
NODE_VERSION: '20' # LTS version for better stability
15+
ARTIFACT_NAME: hyper-light-card.js
16+
ARTIFACT_PATH: ./target/hyper-light-card.js
17+
1318
jobs:
1419
build_and_test:
1520
name: Build + test
1621
runs-on: ubuntu-latest
1722
steps:
18-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v4
1924
- name: Use Node.js
20-
uses: actions/setup-node@v2
21-
with:
22-
node-version: '18'
23-
- name: Cache node modules
24-
uses: actions/cache@v2
25-
env:
26-
cache-name: cache-node-modules
25+
uses: actions/setup-node@v4
2726
with:
28-
path: ~/.npm
29-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
30-
restore-keys: |
31-
${{ runner.os }}-build-${{ env.cache-name }}-
32-
${{ runner.os }}-build-
33-
${{ runner.os }}-
27+
node-version: ${{ env.NODE_VERSION }}
28+
cache: 'npm' # This enables the built-in caching mechanism
3429
- name: Install dependencies
3530
run: npm ci
3631
- name: Run linter
@@ -42,18 +37,21 @@ jobs:
4237
- name: Upload build artifacts
4338
uses: actions/upload-artifact@v4
4439
with:
45-
name: hyper-light-card.js
46-
path: ./target/hyper-light-card.js
40+
name: ${{ env.ARTIFACT_NAME }}
41+
path: ${{ env.ARTIFACT_PATH }}
42+
retention-days: 7 # Keep artifacts for 7 days
43+
4744
analyze:
4845
name: Analyze project
49-
needs: build_and_test
5046
runs-on: ubuntu-latest
47+
# Remove dependency on build_and_test since it doesn't need its artifacts
5148
steps:
52-
- uses: actions/checkout@v2
49+
- uses: actions/checkout@v4
5350
- name: Use Node.js
54-
uses: actions/setup-node@v2
51+
uses: actions/setup-node@v4
5552
with:
56-
node-version: '18'
53+
node-version: ${{ env.NODE_VERSION }}
54+
cache: 'npm'
5755
- name: Install dependencies
5856
run: npm ci
5957
- name: Run ESLint
@@ -70,28 +68,19 @@ jobs:
7068
release:
7169
if: startsWith(github.ref, 'refs/tags/')
7270
needs: build_and_test
71+
permissions:
72+
contents: write
7373
runs-on: ubuntu-latest
7474
steps:
7575
- name: Download build artifact
7676
uses: actions/download-artifact@v4
7777
with:
78-
name: hyper-light-card.js
79-
- name: Create release
80-
id: create_release
81-
uses: actions/create-release@v1
82-
env:
83-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
name: ${{ env.ARTIFACT_NAME }}
79+
- name: Create release and upload asset
80+
uses: softprops/action-gh-release@v2
8481
with:
85-
tag_name: ${{ github.ref }}
86-
release_name: Release ${{ github.ref }}
82+
files: ${{ env.ARTIFACT_NAME }}
83+
name: Release ${{ github.ref_name }}
8784
draft: false
8885
prerelease: false
89-
- name: Upload release asset
90-
uses: actions/upload-release-asset@v1
91-
env:
92-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93-
with:
94-
upload_url: ${{ steps.create_release.outputs.upload_url }}
95-
asset_path: hyper-light-card.js
96-
asset_name: hyper-light-card.js
97-
asset_content_type: application/javascript
86+
generate_release_notes: true

0 commit comments

Comments
Β (0)