|
| 1 | +name: release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v*.*.* |
| 6 | + - "!v*.*.*-**" |
| 7 | +env: |
| 8 | + GOLANG_CI_LINT_VERSION: v1.50.0 |
| 9 | + GOPRIVATE: "github.com/cloudy-sky-software/*" |
| 10 | + PROVIDER: "render" |
| 11 | + NPM_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }} |
| 12 | + PUBLISH_NPM: true |
| 13 | + NPM_REGISTRY_URL: https://registry.npmjs.org |
| 14 | + NUGET_PUBLISH_KEY: ${{ secrets.NUGET_API_KEY }} |
| 15 | + NUGET_FEED_URL: https://api.nuget.org/v3/index.json |
| 16 | + PUBLISH_NUGET: true |
| 17 | + PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 18 | + # PYPI usernames for API tokens is literally __token__. |
| 19 | + PYPI_USERNAME: "__token__" |
| 20 | + PUBLISH_PYPI: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + lint: |
| 24 | + name: Lint |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout Repo |
| 28 | + uses: actions/checkout@v3 |
| 29 | + |
| 30 | + - name: Install Go |
| 31 | + uses: actions/setup-go@v3 |
| 32 | + with: |
| 33 | + go-version: 1.19.x |
| 34 | + |
| 35 | + - run: | |
| 36 | + git config --global url."https://praneetloke:${GH_REPO_PAT}@github.com/".insteadOf "https://github.com/" |
| 37 | + env: |
| 38 | + GH_REPO_PAT: ${{ secrets.GH_REPO_PAT }} |
| 39 | +
|
| 40 | + - name: Lint |
| 41 | + run: | |
| 42 | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $GOLANG_CI_LINT_VERSION |
| 43 | + make lint |
| 44 | +
|
| 45 | + - name: Test |
| 46 | + run: make test |
| 47 | + |
| 48 | + publish-binary: |
| 49 | + name: Publish binary |
| 50 | + runs-on: ${{ matrix.agent-os }} |
| 51 | + needs: lint |
| 52 | + steps: |
| 53 | + - name: Checkout Repo |
| 54 | + uses: actions/checkout@v3 |
| 55 | + |
| 56 | + - run: | |
| 57 | + git config --global url."https://praneetloke:${GH_REPO_PAT}@github.com/".insteadOf "https://github.com/" |
| 58 | + env: |
| 59 | + GH_REPO_PAT: ${{ secrets.GH_REPO_PAT }} |
| 60 | +
|
| 61 | + - name: Unshallow clone for tags |
| 62 | + run: git fetch --prune --unshallow --tags |
| 63 | + |
| 64 | + - name: Install Go |
| 65 | + uses: actions/setup-go@v3 |
| 66 | + with: |
| 67 | + go-version: 1.19.x |
| 68 | + |
| 69 | + - name: Install pulumictl |
| 70 | + uses: jaxxstorm/action-install-gh-release@v1.7.1 |
| 71 | + with: |
| 72 | + repo: pulumi/pulumictl |
| 73 | + tag: "latest" |
| 74 | + env: |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + |
| 77 | + - name: Run GoReleaser |
| 78 | + uses: goreleaser/goreleaser-action@v3 |
| 79 | + with: |
| 80 | + args: -f ${{ matrix.goreleaser }} -p 1 release --rm-dist --timeout 90m0s |
| 81 | + version: latest |
| 82 | + env: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + strategy: |
| 85 | + fail-fast: true |
| 86 | + matrix: |
| 87 | + agent-os: |
| 88 | + - ubuntu-latest |
| 89 | + - macos-latest |
| 90 | + include: |
| 91 | + - agent-os: ubuntu-latest |
| 92 | + goreleaser: .goreleaser.yml |
| 93 | + - agent-os: macos-latest |
| 94 | + goreleaser: .goreleaser.darwin.yml |
| 95 | + |
| 96 | + publish-sdk: |
| 97 | + name: Publish SDKs |
| 98 | + runs-on: ubuntu-latest |
| 99 | + needs: publish-binary |
| 100 | + steps: |
| 101 | + - name: Checkout Repo |
| 102 | + uses: actions/checkout@v3 |
| 103 | + |
| 104 | + - run: | |
| 105 | + git config --global url."https://praneetloke:${GH_REPO_PAT}@github.com/".insteadOf "https://github.com/" |
| 106 | + env: |
| 107 | + GH_REPO_PAT: ${{ secrets.GH_REPO_PAT }} |
| 108 | +
|
| 109 | + - name: Unshallow clone for tags |
| 110 | + run: git fetch --prune --unshallow --tags |
| 111 | + |
| 112 | + - name: Install Go |
| 113 | + uses: actions/setup-go@v3 |
| 114 | + with: |
| 115 | + go-version: ${{ matrix.goversion }} |
| 116 | + |
| 117 | + - name: Install pulumictl |
| 118 | + uses: jaxxstorm/action-install-gh-release@v1.7.1 |
| 119 | + with: |
| 120 | + repo: pulumi/pulumictl |
| 121 | + tag: "latest" |
| 122 | + env: |
| 123 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 124 | + |
| 125 | + - name: Install Pulumi CLI |
| 126 | + uses: pulumi/action-install-pulumi-cli@v2.0.0 |
| 127 | + |
| 128 | + - name: Setup Node |
| 129 | + uses: actions/setup-node@v3 |
| 130 | + with: |
| 131 | + node-version: ${{matrix.nodeversion}} |
| 132 | + registry-url: ${{env.NPM_REGISTRY_URL}} |
| 133 | + |
| 134 | + - name: Setup DotNet |
| 135 | + uses: actions/setup-dotnet@v3 |
| 136 | + with: |
| 137 | + dotnet-version: ${{matrix.dotnetverson}} |
| 138 | + |
| 139 | + - name: Setup Python |
| 140 | + uses: actions/setup-python@v4 |
| 141 | + with: |
| 142 | + python-version: ${{matrix.pythonversion}} |
| 143 | + |
| 144 | + - name: Generate SDK |
| 145 | + run: make gen ${{ matrix.language }}_sdk |
| 146 | + |
| 147 | + - name: Check worktree clean |
| 148 | + run: | |
| 149 | + git update-index -q --refresh |
| 150 | + if ! git diff-files --quiet; then |
| 151 | + >&2 echo "error: working tree is not clean, aborting!" |
| 152 | + git status |
| 153 | + git diff |
| 154 | + exit 1 |
| 155 | + fi |
| 156 | +
|
| 157 | + - name: Compress SDK folder |
| 158 | + run: tar -zcf sdk/${{ matrix.language }}.tar.gz -C sdk/${{ matrix.language }} . |
| 159 | + |
| 160 | + - name: Upload artifacts |
| 161 | + uses: actions/upload-artifact@v3 |
| 162 | + with: |
| 163 | + name: ${{ matrix.language }}-sdk.tar.gz |
| 164 | + path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz |
| 165 | + |
| 166 | + - if: ${{ matrix.language == 'python' && env.PUBLISH_PYPI == 'true' }} |
| 167 | + name: Publish package to PyPI |
| 168 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 169 | + with: |
| 170 | + user: ${{ env.PYPI_USERNAME }} |
| 171 | + password: ${{ env.PYPI_PASSWORD }} |
| 172 | + packages_dir: ${{github.workspace}}/sdk/python/bin/dist |
| 173 | + |
| 174 | + - if: ${{ matrix.language == 'nodejs' && env.PUBLISH_NPM == 'true' }} |
| 175 | + uses: JS-DevTools/npm-publish@v1 |
| 176 | + with: |
| 177 | + access: "public" |
| 178 | + token: ${{ env.NPM_TOKEN }} |
| 179 | + package: ${{github.workspace}}/sdk/nodejs/bin/package.json |
| 180 | + |
| 181 | + - if: ${{ matrix.language == 'dotnet' && env.PUBLISH_NUGET == 'true' }} |
| 182 | + name: publish nuget package |
| 183 | + run: | |
| 184 | + dotnet nuget push ${{github.workspace}}/sdk/dotnet/bin/Debug/*.nupkg -s ${{ env.NUGET_FEED_URL }} -k ${{ env.NUGET_PUBLISH_KEY }} |
| 185 | + echo "done publishing packages" |
| 186 | + strategy: |
| 187 | + fail-fast: true |
| 188 | + matrix: |
| 189 | + dotnetversion: |
| 190 | + - 3.1.301 |
| 191 | + goversion: |
| 192 | + - 1.19.x |
| 193 | + language: |
| 194 | + - nodejs |
| 195 | + - python |
| 196 | + - dotnet |
| 197 | + - go |
| 198 | + nodeversion: |
| 199 | + - 16.x |
| 200 | + pythonversion: |
| 201 | + - "3.9" |
0 commit comments