|
| 1 | +name: Pre-Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + |
| 7 | +jobs: |
| 8 | + package: |
| 9 | + name: Package |
| 10 | + runs-on: ubuntu-22.04 |
| 11 | + outputs: |
| 12 | + packageName: ${{ steps.setup.outputs.packageName }} |
| 13 | + version: ${{ steps.version.outputs.version }} |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v5 |
| 16 | + |
| 17 | + - uses: actions/setup-node@v5 |
| 18 | + with: |
| 19 | + node-version: "22" |
| 20 | + |
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + yarn |
| 24 | + npm install -g @vscode/vsce ovsx |
| 25 | +
|
| 26 | + - name: Generate pre-release version |
| 27 | + id: version |
| 28 | + run: | |
| 29 | + BASE_VERSION=$(node -e "console.log(require('./package.json').version)") |
| 30 | + IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION" |
| 31 | +
|
| 32 | + PRE_MINOR=$((MINOR + 1)) |
| 33 | +
|
| 34 | + DATE_PREFIX=$(date +%Y%m%d) |
| 35 | + BUILD_SUFFIX=$(printf "%02d" $((GITHUB_RUN_NUMBER % 100))) |
| 36 | + DATE_PATCH="${DATE_PREFIX}${BUILD_SUFFIX}" |
| 37 | +
|
| 38 | + # Final version: MAJOR.(MINOR+1).YYYYMMDDNN |
| 39 | + NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}${{ github.run_number }}" |
| 40 | +
|
| 41 | + echo "version=$NUMERIC_VERSION" >> $GITHUB_OUTPUT |
| 42 | +
|
| 43 | + echo "Pre-release version: $NUMERIC_VERSION" |
| 44 | +
|
| 45 | + # Update package.json with the numeric version |
| 46 | + npm version $NUMERIC_VERSION --no-git-tag-version |
| 47 | +
|
| 48 | + - name: Setup package path |
| 49 | + id: setup |
| 50 | + run: | |
| 51 | + PACKAGE_NAME="${{ github.event.repository.name }}-pre-${{ steps.version.outputs.version }}.vsix" |
| 52 | + echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT |
| 53 | +
|
| 54 | + - name: Package extension |
| 55 | + run: vsce package --pre-release --out "${{ steps.setup.outputs.packageName }}" |
| 56 | + |
| 57 | + - name: Upload artifact |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: extension-build-${{ github.run_number }} |
| 61 | + path: ${{ steps.setup.outputs.packageName }} |
| 62 | + if-no-files-found: error |
| 63 | + retention-days: 7 |
| 64 | + |
| 65 | + publishMS: |
| 66 | + name: Publish to VS Marketplace |
| 67 | + runs-on: ubuntu-22.04 |
| 68 | + needs: package |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v5 |
| 71 | + |
| 72 | + - uses: actions/setup-node@v5 |
| 73 | + with: |
| 74 | + node-version: "22" |
| 75 | + |
| 76 | + - name: Install vsce |
| 77 | + run: npm install -g @vscode/vsce |
| 78 | + |
| 79 | + - uses: actions/download-artifact@v5 |
| 80 | + with: |
| 81 | + name: extension-build-${{ github.run_number }} |
| 82 | + |
| 83 | + - name: Publish to VS Marketplace |
| 84 | + run: | |
| 85 | + echo "Publishing version ${{ needs.package.outputs.version }} to VS Marketplace" |
| 86 | + vsce publish --pre-release --packagePath "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }} |
| 87 | +
|
| 88 | + publishOVSX: |
| 89 | + name: Publish to Open VSX |
| 90 | + runs-on: ubuntu-22.04 |
| 91 | + needs: package |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v5 |
| 94 | + |
| 95 | + - uses: actions/setup-node@v5 |
| 96 | + with: |
| 97 | + node-version: "22" |
| 98 | + |
| 99 | + - name: Install ovsx |
| 100 | + run: npm install -g ovsx |
| 101 | + |
| 102 | + - uses: actions/download-artifact@v5 |
| 103 | + with: |
| 104 | + name: extension-build-${{ github.run_number }} |
| 105 | + |
| 106 | + - name: Publish to Open VSX |
| 107 | + run: | |
| 108 | + echo "Publishing version ${{ needs.package.outputs.version }} to Open VSX" |
| 109 | + ovsx publish "./${{ needs.package.outputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }} |
| 110 | +
|
| 111 | + publishGH: |
| 112 | + name: Update Latest Pre-Release |
| 113 | + runs-on: ubuntu-22.04 |
| 114 | + needs: package |
| 115 | + permissions: |
| 116 | + contents: write |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v5 |
| 119 | + |
| 120 | + - uses: actions/download-artifact@v5 |
| 121 | + with: |
| 122 | + name: extension-build-${{ github.run_number }} |
| 123 | + |
| 124 | + - name: Update Rolling Release |
| 125 | + env: |
| 126 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 127 | + run: | |
| 128 | + # Delete old release and tag |
| 129 | + gh release delete latest-pre-release --cleanup-tag -y || true |
| 130 | +
|
| 131 | + # Create new release with heredoc for formatting |
| 132 | + cat << EOF | gh release create latest-pre-release \ |
| 133 | + --target ${{ github.sha }} \ |
| 134 | + --title "Latest Pre-Release Build" \ |
| 135 | + --notes-file - \ |
| 136 | + --prerelease \ |
| 137 | + --latest=false \ |
| 138 | + ${{ needs.package.outputs.packageName }} |
| 139 | + ## Latest Pre-Release: v${{ needs.package.outputs.version }} |
| 140 | +
|
| 141 | + **Build:** #${{ github.run_number }} | **Commit:** ${{ github.sha }} |
| 142 | +
|
| 143 | + ## Changes |
| 144 | + ${{ github.event.head_commit.message }} |
| 145 | +
|
| 146 | + --- |
| 147 | + *This release is automatically updated with each push to main. The tag `latest-pre-release` always points to the most recent build.* |
| 148 | + EOF |
0 commit comments