|
| 1 | +name: Release Extension |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" # Triggers on version tags like v0.0.1, v1.0.0, etc. |
| 7 | + |
| 8 | + # Allow manual triggering of the workflow for exceptional cases, such as re-releasing a specific version. |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + tag: |
| 12 | + description: "The tag version to release (e.g., v1.0.0)" |
| 13 | + required: true |
| 14 | + reason: |
| 15 | + description: "Reason for manually triggering the release" |
| 16 | + required: false |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + packages: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + release: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', github.event.inputs.tag) || github.ref }} |
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: "18" |
| 34 | + cache: "npm" |
| 35 | + - name: Ensure tag matches version in package.json |
| 36 | + run: | |
| 37 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 38 | + TAG_VERSION="${{ github.event.inputs.tag }}" |
| 39 | + else |
| 40 | + TAG_VERSION="${GITHUB_REF##*/}" |
| 41 | + fi |
| 42 | + PKG_VERSION=$(node -p "require('./package.json').version") |
| 43 | + if [ "v$PKG_VERSION" != "$TAG_VERSION" ]; then |
| 44 | + echo "::error::Tag ($TAG_VERSION) does not match package.json version (v$PKG_VERSION)" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + - name: Log manual release reason |
| 48 | + if: github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '' |
| 49 | + run: | |
| 50 | + echo "Manual release reason: ${{ github.event.inputs.reason }}" |
| 51 | +# Removed redundant npm cache step as caching is already handled by setup-node with 'cache: "npm"'. |
| 52 | + - name: Install dependencies |
| 53 | + run: npm ci |
| 54 | + - name: Run quality checks |
| 55 | + run: npm run quality |
| 56 | + - name: Build extension |
| 57 | + run: npm run build |
| 58 | + - name: Package extension |
| 59 | + run: npx @vscode/vsce package |
| 60 | + - name: Check VSIX exists |
| 61 | + run: | |
| 62 | + if ! ls *.vsix > /dev/null 2>&1; then |
| 63 | + echo "::error::VSIX package not found!" |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + - name: Upload VSIX as artifact |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + with: |
| 69 | + name: ash-studio-extension |
| 70 | + path: "*.vsix" |
| 71 | + retention-days: 30 |
| 72 | + - name: Create Release |
| 73 | + uses: softprops/action-gh-release@v1 |
| 74 | + with: |
| 75 | + files: "*.vsix" |
| 76 | + generate_release_notes: true |
| 77 | + env: |
| 78 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments