|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + tag_name: |
| 7 | + description: "Tag name for the release" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + prerelease: |
| 11 | + description: "Is this a pre-release?" |
| 12 | + required: true |
| 13 | + type: boolean |
| 14 | + vsix_artifact_name: |
| 15 | + description: "Name of the VSIX artifact to download" |
| 16 | + required: false |
| 17 | + type: string |
| 18 | + default: "vsix-artifact" |
| 19 | + workflow_run_id: |
| 20 | + description: "Workflow run ID to download artifacts from" |
| 21 | + required: false |
| 22 | + type: string |
| 23 | + |
| 24 | +env: |
| 25 | + HUSKY: 0 |
| 26 | + |
| 27 | +jobs: |
| 28 | + generate_changelog: |
| 29 | + name: Generate Changelog |
| 30 | + uses: konveyor/release-tools/.github/workflows/generate-changelog.yml@main |
| 31 | + with: |
| 32 | + version: ${{ inputs.tag_name }} |
| 33 | + prev_version: $(gh api repos/${{ github.repository }}/releases/latest | jq -r '.tag_name') |
| 34 | + repository: ${{ github.repository }} |
| 35 | + ref: ${{ github.sha }} |
| 36 | + secrets: |
| 37 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + |
| 39 | + release: |
| 40 | + name: Final Release |
| 41 | + runs-on: ubuntu-latest |
| 42 | + needs: generate_changelog |
| 43 | + steps: |
| 44 | + - name: Add release details to the step summary |
| 45 | + run: | |
| 46 | + cat >> "$GITHUB_STEP_SUMMARY" <<EOF |
| 47 | + ## Release Information |
| 48 | + Tag: __${{ inputs.tag_name }}__ |
| 49 | + Pre-Release: __${{ inputs.prerelease }}__ |
| 50 | + VSIX Artifact: __${{ inputs.vsix_artifact_name }}__ |
| 51 | + Workflow Run ID: __${{ inputs.workflow_run_id || github.run_id }}__ |
| 52 | + EOF |
| 53 | +
|
| 54 | + - name: Checkout code |
| 55 | + uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Download Changelog Artifact |
| 58 | + uses: actions/download-artifact@v4 |
| 59 | + with: |
| 60 | + name: changelog-artifact |
| 61 | + path: ./artifacts |
| 62 | + |
| 63 | + - name: Download VSIX Artifact |
| 64 | + uses: actions/download-artifact@v4 |
| 65 | + with: |
| 66 | + name: ${{ inputs.vsix_artifact_name }} |
| 67 | + path: ./artifacts |
| 68 | + |
| 69 | + - name: Verify Downloaded Artifacts |
| 70 | + run: ls -R ./artifacts/ |
| 71 | + |
| 72 | + - name: Find and set VSIX filename |
| 73 | + id: vsix_info |
| 74 | + run: | |
| 75 | + VSIX_FILE=$(find ./artifacts -name "*.vsix" -type f | head -1) |
| 76 | + VSIX_NAME=$(basename "$VSIX_FILE") |
| 77 | + echo "vsix_path=$VSIX_FILE" >> "$GITHUB_OUTPUT" |
| 78 | + echo "vsix_name=$VSIX_NAME" >> "$GITHUB_OUTPUT" |
| 79 | + echo "Found VSIX: $VSIX_NAME at $VSIX_FILE" |
| 80 | +
|
| 81 | + - name: Set up Node.js for publishing |
| 82 | + uses: actions/setup-node@v4 |
| 83 | + with: |
| 84 | + node-version-file: ".nvmrc" |
| 85 | + |
| 86 | + - name: Publish to VS Code Marketplace |
| 87 | + if: ${{ inputs.prerelease == false }} |
| 88 | + run: | |
| 89 | + echo "Publishing ${{ steps.vsix_info.outputs.vsix_path }}" |
| 90 | + if [ -f "./artifacts/release.md" ]; then |
| 91 | + echo "Publishing with changelog" |
| 92 | + npx @vscode/vsce publish --packagePath "${{ steps.vsix_info.outputs.vsix_path }}" --changelog-path "./artifacts/release.md" |
| 93 | + else |
| 94 | + echo "Publishing without changelog (file not found)" |
| 95 | + npx @vscode/vsce publish --packagePath "${{ steps.vsix_info.outputs.vsix_path }}" |
| 96 | + fi |
| 97 | + env: |
| 98 | + VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} |
| 99 | + |
| 100 | + - name: Create Release |
| 101 | + uses: ncipollo/release-action@v1 |
| 102 | + with: |
| 103 | + tag: ${{ inputs.tag_name }} |
| 104 | + commit: ${{ github.sha }} |
| 105 | + bodyFile: ./artifacts/release.md |
| 106 | + artifacts: | |
| 107 | + ${{ steps.vsix_info.outputs.vsix_path }} |
| 108 | + prerelease: ${{ inputs.prerelease }} |
| 109 | + env: |
| 110 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments