|
| 1 | +name: ✨ LightScript Workshop |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "v*.*.*" |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +env: |
| 14 | + NODE_VERSION: "20" # Current LTS version |
| 15 | + ARTIFACT_NAME: lightscript-workshop.js |
| 16 | + ARTIFACT_PATH: ./target/lightscript-workshop.js |
| 17 | + |
| 18 | +jobs: |
| 19 | + build_and_test: |
| 20 | + name: 🔨 Build + Test |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: 📥 Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: 🔧 Setup Node.js ${{ env.NODE_VERSION }} |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: ${{ env.NODE_VERSION }} |
| 30 | + cache: "npm" |
| 31 | + cache-dependency-path: "**/package-lock.json" |
| 32 | + |
| 33 | + - name: 📦 Install dependencies |
| 34 | + run: npm ci |
| 35 | + |
| 36 | + - name: 🧹 Run linter |
| 37 | + run: npm run lint |
| 38 | + |
| 39 | + - name: 🧪 Run tests |
| 40 | + run: npm test |
| 41 | + |
| 42 | + - name: 🏗️ Build project |
| 43 | + run: npm run build |
| 44 | + |
| 45 | + - name: 📤 Upload build artifacts |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: ${{ env.ARTIFACT_NAME }} |
| 49 | + path: ${{ env.ARTIFACT_PATH }} |
| 50 | + retention-days: 7 # Keep artifacts for 7 days |
| 51 | + |
| 52 | + analyze: |
| 53 | + name: 🔍 Analyze Project |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - name: 📥 Checkout code |
| 57 | + uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: 🔧 Setup Node.js ${{ env.NODE_VERSION }} |
| 60 | + uses: actions/setup-node@v4 |
| 61 | + with: |
| 62 | + node-version: ${{ env.NODE_VERSION }} |
| 63 | + cache: "npm" |
| 64 | + cache-dependency-path: "**/package-lock.json" |
| 65 | + |
| 66 | + - name: 📦 Install dependencies |
| 67 | + run: npm ci |
| 68 | + |
| 69 | + - name: 🧹 Run ESLint |
| 70 | + run: npm run lint |
| 71 | + continue-on-error: true |
| 72 | + |
| 73 | + - name: 🔎 TypeScript type check |
| 74 | + run: npx tsc --noEmit |
| 75 | + continue-on-error: true |
| 76 | + |
| 77 | + release: |
| 78 | + name: 🚀 Release |
| 79 | + if: startsWith(github.ref, 'refs/tags/') |
| 80 | + needs: build_and_test |
| 81 | + permissions: |
| 82 | + contents: write |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - name: 📥 Download build artifact |
| 86 | + uses: actions/download-artifact@v4 |
| 87 | + with: |
| 88 | + name: ${{ env.ARTIFACT_NAME }} |
| 89 | + |
| 90 | + - name: 🎉 Create GitHub Release |
| 91 | + uses: softprops/action-gh-release@v2 |
| 92 | + with: |
| 93 | + files: ${{ env.ARTIFACT_NAME }} |
| 94 | + name: Release ${{ github.ref_name }} |
| 95 | + draft: false |
| 96 | + prerelease: false |
| 97 | + generate_release_notes: true |
0 commit comments