Build backend into docker image and push to GH registry #97
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build VSCode Extensions | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| pull_request: | |
| paths-ignore: | |
| - 'docs/**' | |
| - 'README.md' | |
| - 'zensical.toml' | |
| jobs: | |
| prepare: | |
| name: Prepare Build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| semver: ${{ steps.version.outputs.semver }} | |
| is_prerelease: ${{ steps.version.outputs.is_prerelease }} | |
| prerelease_flag: ${{ steps.version.outputs.prerelease_flag }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| VERSION="${{ github.event.release.tag_name }}" | |
| SEMVER="${VERSION#v}" | |
| # VSCode only supports major.minor.patch, no pre-release tags | |
| if [[ "$SEMVER" == *-* ]]; then | |
| echo "Error: VSCode versions must be clean semver (major.minor.patch) without pre-release tags" | |
| echo "Found: $SEMVER" | |
| echo "Use GitHub's pre-release flag instead of version suffixes" | |
| exit 1 | |
| fi | |
| IS_PRERELEASE="${{ github.event.release.prerelease }}" | |
| if [[ "$IS_PRERELEASE" == "true" ]]; then | |
| PRERELEASE_FLAG="--pre-release" | |
| else | |
| PRERELEASE_FLAG="" | |
| fi | |
| else | |
| VERSION="dev-$(git rev-parse --short HEAD)" | |
| SEMVER="0.0.0" | |
| IS_PRERELEASE="false" | |
| PRERELEASE_FLAG="" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "semver=$SEMVER" >> $GITHUB_OUTPUT | |
| echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT | |
| echo "prerelease_flag=$PRERELEASE_FLAG" >> $GITHUB_OUTPUT | |
| - name: Update package.json versions | |
| run: | | |
| jq --arg version "${{ steps.version.outputs.semver }}" '.version = $version' package.json > package.json.tmp | |
| mv package.json.tmp package.json | |
| jq --arg version "${{ steps.version.outputs.semver }}" '.version = $version' src/extensions/core/package.json > src/extensions/core/package.json.tmp | |
| mv src/extensions/core/package.json.tmp src/extensions/core/package.json | |
| jq --arg version "${{ steps.version.outputs.semver }}" '.version = $version' src/extensions/fprime/package.json > src/extensions/fprime/package.json.tmp | |
| mv src/extensions/fprime/package.json.tmp src/extensions/fprime/package.json | |
| - name: Upload versioned package.json files | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: package-jsons | |
| path: | | |
| package.json | |
| src/extensions/core/package.json | |
| src/extensions/fprime/package.json | |
| retention-days: 1 | |
| build-typescript: | |
| name: Build TypeScript | |
| runs-on: ubuntu-latest | |
| needs: prepare | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download versioned package.json files | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: package-jsons | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build TypeScript extensions | |
| run: yarn build | |
| - name: Upload TypeScript build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: typescript-build | |
| path: | | |
| out/ | |
| src/extensions/*/out/ | |
| retention-days: 1 | |
| build-backend: | |
| name: Build Backend ${{ matrix.platform }} | |
| runs-on: ubuntu-latest | |
| needs: prepare | |
| strategy: | |
| matrix: | |
| platform: | |
| - linux-x64 | |
| - linux-arm64 | |
| - darwin-x64 | |
| - darwin-arm64 | |
| - win32-x64 | |
| - win32-arm64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| cache: true | |
| - name: Map VSCode platform to Go platform | |
| id: go-platform | |
| run: | | |
| PLATFORM="${{ matrix.platform }}" | |
| case "$PLATFORM" in | |
| linux-x64) | |
| GOOS="linux" | |
| GOARCH="amd64" | |
| ;; | |
| linux-arm64) | |
| GOOS="linux" | |
| GOARCH="arm64" | |
| ;; | |
| darwin-x64) | |
| GOOS="darwin" | |
| GOARCH="amd64" | |
| ;; | |
| darwin-arm64) | |
| GOOS="darwin" | |
| GOARCH="arm64" | |
| ;; | |
| win32-x64) | |
| GOOS="windows" | |
| GOARCH="amd64" | |
| ;; | |
| win32-arm64) | |
| GOOS="windows" | |
| GOARCH="arm64" | |
| ;; | |
| *) | |
| echo "Unknown platform: $PLATFORM" | |
| exit 1 | |
| ;; | |
| esac | |
| echo "goos=$GOOS" >> $GITHUB_OUTPUT | |
| echo "goarch=$GOARCH" >> $GITHUB_OUTPUT | |
| - name: Build backend binary | |
| env: | |
| GOOS: ${{ steps.go-platform.outputs.goos }} | |
| GOARCH: ${{ steps.go-platform.outputs.goarch }} | |
| CGO_ENABLED: 0 | |
| GO_FLAGS: -trimpath -ldflags="-s -w" | |
| run: make out/backend | |
| - name: Upload backend binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-${{ matrix.platform }} | |
| path: out/backend* | |
| retention-days: 1 | |
| package-core: | |
| name: Package Core ${{ matrix.platform }} | |
| runs-on: ubuntu-latest | |
| needs: [prepare, build-typescript, build-backend] | |
| strategy: | |
| matrix: | |
| platform: | |
| - linux-x64 | |
| - linux-arm64 | |
| - darwin-x64 | |
| - darwin-arm64 | |
| - win32-x64 | |
| - win32-arm64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download versioned package.json files | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: package-jsons | |
| - name: Download TypeScript build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: typescript-build | |
| - name: Download backend binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: backend-${{ matrix.platform }} | |
| path: out/ | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Install vsce | |
| run: npm install -g @vscode/vsce | |
| - name: Map platform for backend file extension | |
| id: platform-map | |
| run: | | |
| if [[ "${{ matrix.platform }}" == win32-* ]]; then | |
| echo "backend_file=backend.exe" >> $GITHUB_OUTPUT | |
| else | |
| echo "backend_file=backend" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Copy backend to extension directory | |
| run: | | |
| mkdir -p src/extensions/core/out | |
| cp out/backend src/extensions/core/out/${{ steps.platform-map.outputs.backend_file }} | |
| if [[ "${{ matrix.platform }}" != win32-* ]]; then | |
| chmod +x src/extensions/core/out/${{ steps.platform-map.outputs.backend_file }} | |
| fi | |
| - name: Package core extension | |
| run: | | |
| cd src/extensions/core | |
| vsce package --yarn --target ${{ matrix.platform }} -o ../../../hermes-${{ needs.prepare.outputs.version }}-${{ matrix.platform }}.vsix | |
| - name: Upload core extension artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hermes-${{ needs.prepare.outputs.version }}-${{ matrix.platform }} | |
| path: hermes-${{ needs.prepare.outputs.version }}-${{ matrix.platform }}.vsix | |
| retention-days: 30 | |
| - name: Upload core extension to release | |
| if: github.event_name == 'release' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: hermes-${{ needs.prepare.outputs.version }}-${{ matrix.platform }}.vsix | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| package-fprime: | |
| name: Package FPrime Extension | |
| runs-on: ubuntu-latest | |
| needs: [prepare, build-typescript] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download versioned package.json files | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: package-jsons | |
| - name: Download TypeScript build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: typescript-build | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Install vsce | |
| run: npm install -g @vscode/vsce | |
| - name: Package fprime extension | |
| run: | | |
| cd src/extensions/fprime | |
| vsce package -o ../../../hermes-fprime-${{ needs.prepare.outputs.version }}.vsix | |
| - name: Upload fprime extension artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hermes-fprime-${{ needs.prepare.outputs.version }} | |
| path: hermes-fprime-${{ needs.prepare.outputs.version }}.vsix | |
| retention-days: 30 | |
| - name: Upload fprime extension to release | |
| if: github.event_name == 'release' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: hermes-fprime-${{ needs.prepare.outputs.version }}.vsix | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-core: | |
| name: Publish Core to Marketplace | |
| runs-on: ubuntu-latest | |
| needs: [prepare, package-core] | |
| if: github.event_name == 'release' | |
| strategy: | |
| matrix: | |
| platform: | |
| - linux-x64 | |
| - linux-arm64 | |
| - darwin-x64 | |
| - darwin-arm64 | |
| - win32-x64 | |
| - win32-arm64 | |
| steps: | |
| - name: Download core extension artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: hermes-${{ needs.prepare.outputs.version }}-${{ matrix.platform }} | |
| - name: Install vsce | |
| run: npm install -g @vscode/vsce | |
| - name: Publish core extension | |
| run: vsce publish --packagePath hermes-${{ needs.prepare.outputs.version }}-${{ matrix.platform }}.vsix ${{ needs.prepare.outputs.prerelease_flag }} | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| publish-fprime: | |
| name: Publish FPrime to Marketplace | |
| runs-on: ubuntu-latest | |
| needs: [prepare, package-fprime] | |
| if: github.event_name == 'release' | |
| steps: | |
| - name: Download fprime extension artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: hermes-fprime-${{ needs.prepare.outputs.version }} | |
| - name: Install vsce | |
| run: npm install -g @vscode/vsce | |
| - name: Publish fprime extension | |
| run: vsce publish --packagePath hermes-fprime-${{ needs.prepare.outputs.version }}.vsix ${{ needs.prepare.outputs.prerelease_flag }} | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} |