Add automatic npm publishing to release workflow #2
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: Release CLI Binaries | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| goos: linux | |
| goarch: amd64 | |
| ext: '' | |
| name: ue-cli-linux-amd64 | |
| - os: ubuntu-latest | |
| goos: linux | |
| goarch: arm64 | |
| ext: '' | |
| name: ue-cli-linux-arm64 | |
| - os: ubuntu-latest | |
| goos: darwin | |
| goarch: amd64 | |
| ext: '' | |
| name: ue-cli-darwin-amd64 | |
| - os: ubuntu-latest | |
| goos: darwin | |
| goarch: arm64 | |
| ext: '' | |
| name: ue-cli-darwin-arm64 | |
| - os: ubuntu-latest | |
| goos: windows | |
| goarch: amd64 | |
| ext: '.exe' | |
| name: ue-cli-windows-amd64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Copy plugin source for embedding | |
| run: | | |
| mkdir -p cli/internal/project/plugin | |
| cp UnrealMCP.uplugin cli/internal/project/plugin/ | |
| cp -r Source cli/internal/project/plugin/ | |
| - name: Build | |
| working-directory: cli | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: '0' | |
| run: | | |
| VERSION="${GITHUB_REF_NAME}" | |
| go build -ldflags "-s -w -X github.com/epicgames/ue-cli/cmd.Version=${VERSION}" \ | |
| -o "../${{ matrix.name }}${{ matrix.ext }}" . | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.name }} | |
| path: ${{ matrix.name }}${{ matrix.ext }} | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: binaries | |
| merge-multiple: true | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| files: | | |
| binaries/ue-cli-windows-amd64.exe | |
| binaries/ue-cli-linux-amd64 | |
| binaries/ue-cli-linux-arm64 | |
| binaries/ue-cli-darwin-amd64 | |
| binaries/ue-cli-darwin-arm64 | |
| publish-npm: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm package version from tag | |
| working-directory: cli/npm | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| npm version "$VERSION" --no-git-tag-version --allow-same-version | |
| - name: Publish to npm | |
| working-directory: cli/npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access public |