make chagnes in go sdk so that go version will work #8
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| permissions: | |
| contents: write # create GitHub releases and upload assets | |
| env: | |
| PROVIDER: pulumi-resource-devzero | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.os }}/${{ matrix.arch }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - os: linux | |
| arch: amd64 | |
| - os: linux | |
| arch: arm64 | |
| - os: darwin | |
| arch: amd64 | |
| - os: darwin | |
| arch: arm64 | |
| - os: windows | |
| arch: amd64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Get version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Build provider binary | |
| env: | |
| GOOS: ${{ matrix.os }} | |
| GOARCH: ${{ matrix.arch }} | |
| CGO_ENABLED: "0" | |
| run: | | |
| mkdir -p dist | |
| EXT="" | |
| [ "${{ matrix.os }}" = "windows" ] && EXT=".exe" | |
| go build -o dist/${PROVIDER}${EXT} \ | |
| -ldflags "-X main.version=v${{ steps.version.outputs.VERSION }}" \ | |
| ./provider/cmd/${PROVIDER}/... | |
| - name: Package binary as tarball | |
| run: | | |
| VERSION=${{ steps.version.outputs.VERSION }} | |
| ARCHIVE="${PROVIDER}-v${VERSION}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz" | |
| cd dist && tar -czf "../${ARCHIVE}" ${PROVIDER}* | |
| - name: Upload binary artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.PROVIDER }}-v${{ steps.version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }} | |
| path: ${{ env.PROVIDER }}-v${{ steps.version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz | |
| retention-days: 1 | |
| # ----------------------------------------------------------------------- | |
| # Publish Node.js SDK to npm | |
| # SDKs are already committed to the repo by gen-sdk.yml; just stamp the | |
| # version, build, and publish. | |
| # ----------------------------------------------------------------------- | |
| publish-nodejs: | |
| name: Publish Node.js SDK | |
| runs-on: ubuntu-latest | |
| needs: build | |
| environment: release # requires approval from a maintainer in GitHub Environments | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Get version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Stamp version into package.json | |
| run: | | |
| cd sdk/nodejs | |
| npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version | |
| - name: Install and build | |
| working-directory: sdk/nodejs | |
| run: | | |
| npm install | |
| npm run build | |
| - name: Publish to npm | |
| working-directory: sdk/nodejs | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # ----------------------------------------------------------------------- | |
| # Publish Python SDK to PyPI | |
| # SDKs are already committed to the repo by gen-sdk.yml; just stamp the | |
| # version and publish. | |
| # ----------------------------------------------------------------------- | |
| publish-python: | |
| name: Publish Python SDK | |
| runs-on: ubuntu-latest | |
| needs: build | |
| environment: release # requires approval from a maintainer in GitHub Environments | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Get version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Stamp version into setup.py | |
| run: | | |
| sed -i 's/VERSION = "0\.0\.0"/VERSION = "${{ steps.version.outputs.VERSION }}"/' sdk/python/setup.py | |
| - name: Install build tools | |
| run: pip install build twine | |
| - name: Build Python package | |
| working-directory: sdk/python | |
| run: python -m build | |
| - name: Publish to PyPI | |
| working-directory: sdk/python | |
| run: twine upload dist/* | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| # ----------------------------------------------------------------------- | |
| # Tag Go SDK for pkg.go.dev | |
| # Go requires a submodule tag (sdk/go/devzero/vX.Y.Z) for `go get` to | |
| # resolve the module at sdk/go/devzero. | |
| # ----------------------------------------------------------------------- | |
| tag-go-sdk: | |
| name: Tag Go SDK | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create Go SDK submodule tag | |
| run: | | |
| git tag sdk/go/devzero/${{ github.ref_name }} | |
| git push origin sdk/go/devzero/${{ github.ref_name }} | |
| # ----------------------------------------------------------------------- | |
| # Create GitHub Release and attach provider binaries | |
| # Pulumi CLI resolves `pulumi plugin install` from these release assets. | |
| # ----------------------------------------------------------------------- | |
| github-release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [publish-nodejs, publish-python, tag-go-sdk] | |
| environment: release # requires approval from a maintainer in GitHub Environments | |
| steps: | |
| - name: Get version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Download all binary artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Generate checksums | |
| run: | | |
| cd dist | |
| sha256sum *.tar.gz > checksums.txt | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: v${{ steps.version.outputs.VERSION }} | |
| tag_name: ${{ github.ref_name }} | |
| generate_release_notes: true | |
| files: | | |
| dist/*.tar.gz | |
| dist/checksums.txt |