|
| 1 | +name: MTA Build & Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + upload_artifacts: |
| 7 | + description: "Upload artifacts as workflow artifacts" |
| 8 | + required: false |
| 9 | + default: true |
| 10 | + type: boolean |
| 11 | + push: |
| 12 | + tags: |
| 13 | + - "mta-*" |
| 14 | + - "v*-mta" |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: mta-build-${{ github.event_name }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +env: |
| 21 | + HUSKY: 0 |
| 22 | + |
| 23 | +jobs: |
| 24 | + build-mta-extension: |
| 25 | + name: Build MTA Extension |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Get GitHub App Token |
| 30 | + id: app-token |
| 31 | + uses: actions/create-github-app-token@v1 |
| 32 | + with: |
| 33 | + app-id: ${{ vars.MIGTOOLS_BOT_ID }} |
| 34 | + private-key: ${{ secrets.MIGTOOLS_BOT_KEY }} |
| 35 | + |
| 36 | + - name: Checkout code |
| 37 | + uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + fetch-depth: 0 |
| 40 | + token: ${{ steps.app-token.outputs.token }} |
| 41 | + |
| 42 | + - name: Get upstream Konveyor SHA |
| 43 | + id: upstream_sha |
| 44 | + run: | |
| 45 | + # Add konveyor remote if it doesn't exist |
| 46 | + git remote add konveyor https://github.com/konveyor/editor-extensions.git 2>/dev/null || true |
| 47 | + git fetch konveyor main |
| 48 | +
|
| 49 | + # Find the merge base (last common commit) between current branch and konveyor/main |
| 50 | + UPSTREAM_SHA=$(git merge-base HEAD konveyor/main) |
| 51 | + UPSTREAM_SHA_SHORT=$(git rev-parse --short $UPSTREAM_SHA) |
| 52 | +
|
| 53 | + echo "upstream_sha=${UPSTREAM_SHA}" >> $GITHUB_OUTPUT |
| 54 | + echo "upstream_sha_short=${UPSTREAM_SHA_SHORT}" >> $GITHUB_OUTPUT |
| 55 | +
|
| 56 | + echo "## Upstream Information" >> $GITHUB_STEP_SUMMARY |
| 57 | + echo "- **Upstream SHA**: [\`${UPSTREAM_SHA_SHORT}\`](https://github.com/konveyor/editor-extensions/commit/${UPSTREAM_SHA})" >> $GITHUB_STEP_SUMMARY |
| 58 | + echo "- **Downstream SHA**: [\`${GITHUB_SHA:0:7}\`](https://github.com/${{ github.repository }}/commit/${GITHUB_SHA})" >> $GITHUB_STEP_SUMMARY |
| 59 | +
|
| 60 | + - name: Setup Node.js |
| 61 | + uses: actions/setup-node@v4 |
| 62 | + with: |
| 63 | + node-version-file: ".nvmrc" |
| 64 | + cache: "npm" |
| 65 | + |
| 66 | + - name: Install workspace dependencies |
| 67 | + run: npm ci |
| 68 | + |
| 69 | + - name: Collect runtime assets |
| 70 | + run: npm run collect-assets |
| 71 | + |
| 72 | + - name: Build all workspaces |
| 73 | + run: npm run build |
| 74 | + env: |
| 75 | + UPSTREAM_GIT_SHA: ${{ steps.upstream_sha.outputs.upstream_sha }} |
| 76 | + |
| 77 | + - name: Create distribution package |
| 78 | + run: npm run dist |
| 79 | + |
| 80 | + - name: Package VSIX |
| 81 | + run: npm run package |
| 82 | + |
| 83 | + - name: Get package info |
| 84 | + id: package_info |
| 85 | + run: | |
| 86 | + PACKAGE_NAME=$(node -p "require('./dist/package.json').name") |
| 87 | + PACKAGE_VERSION=$(node -p "require('./dist/package.json').version") |
| 88 | + VSIX_FILE="${PACKAGE_NAME}-${PACKAGE_VERSION}.vsix" |
| 89 | +
|
| 90 | + # Create build metadata |
| 91 | + BUILD_INFO="Built from konveyor/editor-extensions@${{ steps.upstream_sha.outputs.upstream_sha_short }}" |
| 92 | +
|
| 93 | + echo "package_name=${PACKAGE_NAME}" >> $GITHUB_OUTPUT |
| 94 | + echo "package_version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT |
| 95 | + echo "vsix_file=${VSIX_FILE}" >> $GITHUB_OUTPUT |
| 96 | + echo "vsix_path=./dist/${VSIX_FILE}" >> $GITHUB_OUTPUT |
| 97 | + echo "build_info=${BUILD_INFO}" >> $GITHUB_OUTPUT |
| 98 | +
|
| 99 | + - name: Verify VSIX file exists |
| 100 | + run: | |
| 101 | + if [ ! -f "${{ steps.package_info.outputs.vsix_path }}" ]; then |
| 102 | + echo "VSIX file not found: ${{ steps.package_info.outputs.vsix_path }}" |
| 103 | + ls -la ./dist/ |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | + echo "VSIX file found: ${{ steps.package_info.outputs.vsix_path }}" |
| 107 | +
|
| 108 | + - name: Upload VSIX as workflow artifact |
| 109 | + if: ${{ inputs.upload_artifacts != false }} |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + with: |
| 112 | + name: mta-vsix-${{ steps.package_info.outputs.package_version }} |
| 113 | + path: ${{ steps.package_info.outputs.vsix_path }} |
| 114 | + retention-days: 30 |
| 115 | + |
| 116 | + - name: Create GitHub Release (on tag) |
| 117 | + if: startsWith(github.ref, 'refs/tags/') |
| 118 | + uses: softprops/action-gh-release@v2 |
| 119 | + with: |
| 120 | + files: ${{ steps.package_info.outputs.vsix_path }} |
| 121 | + name: MTA Extension ${{ steps.package_info.outputs.package_version }} |
| 122 | + body: | |
| 123 | + ## MTA Extension Release ${{ steps.package_info.outputs.package_version }} |
| 124 | +
|
| 125 | + Migration Toolkit for Applications VS Code Extension |
| 126 | +
|
| 127 | + ### Build Information |
| 128 | + - **Based on**: [konveyor/editor-extensions@${{ steps.upstream_sha.outputs.upstream_sha_short }}](https://github.com/konveyor/editor-extensions/commit/${{ steps.upstream_sha.outputs.upstream_sha }}) |
| 129 | + - **Built**: ${{ github.run_id }} on ${{ github.ref_name }} |
| 130 | +
|
| 131 | + ### Installation |
| 132 | + Download the `.vsix` file and install it in VS Code: |
| 133 | + ``` |
| 134 | + code --install-extension ${{ steps.package_info.outputs.vsix_file }} |
| 135 | + ``` |
| 136 | +
|
| 137 | + Or use the VS Code Extensions view: Extensions → Views and More Actions → Install from VSIX |
| 138 | + env: |
| 139 | + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
| 140 | + |
| 141 | + - name: Summary |
| 142 | + run: | |
| 143 | + echo "## Build Summary" >> $GITHUB_STEP_SUMMARY |
| 144 | + echo "- **Package**: ${{ steps.package_info.outputs.package_name }}" >> $GITHUB_STEP_SUMMARY |
| 145 | + echo "- **Version**: ${{ steps.package_info.outputs.package_version }}" >> $GITHUB_STEP_SUMMARY |
| 146 | + echo "- **VSIX File**: ${{ steps.package_info.outputs.vsix_file }}" >> $GITHUB_STEP_SUMMARY |
| 147 | + echo "- **Trigger**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY |
| 148 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 149 | + echo "- **Tag**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY |
| 150 | + fi |
0 commit comments