Skip to content

Commit 340773b

Browse files
author
Hayden Young
committed
feat(ci): github actions
1 parent c03ed86 commit 340773b

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

.github/workflows/release.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
name: release
3+
on:
4+
push:
5+
tags:
6+
- v*.*.*
7+
env:
8+
# THIS GITHUB_TOKEN IS A REQUIREMENT TO BE ABLE TO WRITE TO GH RELEASES
9+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+
# IF YOU NEED TO PUBLISH A NPM PACKAGE THEN ENSURE A NPM_TOKEN SECRET IS SET
11+
# AND PUBLISH_NPM: TRUE. IF YOU WANT TO PUBLISH TO A PRIVATE NPM REGISTRY
12+
# THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED
13+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
14+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
15+
PUBLISH_NPM: true
16+
NPM_REGISTRY_URL: https://registry.npmjs.org
17+
# IF YOU NEED TO PUBLISH A NUGET PACKAGE THEN ENSURE AN NUGET_PUBLISH_KEY
18+
# SECRET IS SET AND PUBLISH_NUGET: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE
19+
# NPM REGISTRY THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED
20+
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
21+
NUGET_FEED_URL: https://api.nuget.org/v3/index.json
22+
PUBLISH_NUGET: true
23+
# IF YOU NEED TO PUBLISH A PYPI PACKAGE THEN ENSURE AN PYPI_API_TOKEN
24+
# SECRET IS SET AND PUBLISH_PYPI: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE
25+
# PYPI REGISTRY THEN ENSURE THE PYPI_REPOSITORY_URL IS SET. IF YOU ARE USING AN API_TOKEN THEN
26+
# YOU DO NOT NEED TO CHANGE THE PYPI_USERNAME (__token__) , IF YOU ARE USING PASSWORD AUTHENTICATION THEN YOU WILL
27+
# NEED TO CHANGE TO USE THE CORRECT PASSWORD
28+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
PYPI_USERNAME: "__token__"
30+
PYPI_REPOSITORY_URL: ""
31+
PUBLISH_PYPI: true
32+
jobs:
33+
publish_binary:
34+
name: publish
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout Repo
38+
uses: actions/checkout@v2
39+
- name: Unshallow clone for tags
40+
run: git fetch --prune --unshallow --tags
41+
- name: Install Go
42+
uses: actions/setup-go@v2
43+
with:
44+
go-version: ${{matrix.goversion}}
45+
- name: Install pulumictl
46+
uses: jaxxstorm/[email protected]
47+
with:
48+
repo: pulumi/pulumictl
49+
- name: Set PreRelease Version
50+
run: echo "GORELEASER_CURRENT_TAG=v$(pulumictl get version --language generic)" >> $GITHUB_ENV
51+
- name: Run GoReleaser
52+
uses: goreleaser/goreleaser-action@v2
53+
with:
54+
args: -p 3 release --rm-dist
55+
version: latest
56+
strategy:
57+
fail-fast: true
58+
matrix:
59+
goversion:
60+
- 1.17.x
61+
publish_sdk:
62+
name: Publish SDKs
63+
runs-on: ubuntu-latest
64+
needs: publish_binary
65+
steps:
66+
- name: Checkout Repo
67+
uses: actions/checkout@v2
68+
- name: Unshallow clone for tags
69+
run: git fetch --prune --unshallow --tags
70+
- name: Install Go
71+
uses: actions/setup-go@v2
72+
with:
73+
go-version: ${{ matrix.goversion }}
74+
- name: Install pulumictl
75+
uses: jaxxstorm/[email protected]
76+
with:
77+
repo: pulumi/pulumictl
78+
- name: Install Pulumi CLI
79+
uses: pulumi/[email protected]
80+
- name: Setup Node
81+
uses: actions/setup-node@v1
82+
with:
83+
node-version: ${{matrix.nodeversion}}
84+
registry-url: ${{env.NPM_REGISTRY_URL}}
85+
- name: Setup DotNet
86+
uses: actions/setup-dotnet@v1
87+
with:
88+
dotnet-version: ${{matrix.dotnetverson}}
89+
- name: Setup Python
90+
uses: actions/setup-python@v1
91+
with:
92+
python-version: ${{matrix.pythonversion}}
93+
- name: Build SDK
94+
run: make build_${{ matrix.language }}_sdk
95+
- name: Check worktree clean
96+
run: |
97+
git update-index -q --refresh
98+
if ! git diff-files --quiet; then
99+
>&2 echo "error: working tree is not clean, aborting!"
100+
git status
101+
git diff
102+
exit 1
103+
fi
104+
- if: ${{ matrix.language == 'python' && env.PUBLISH_PYPI == 'true' }}
105+
name: Publish package to PyPI
106+
uses: pypa/gh-action-pypi-publish@release/v1
107+
with:
108+
user: ${{ env.PYPI_USERNAME }}
109+
password: ${{ env.PYPI_PASSWORD }}
110+
packages_dir: ${{github.workspace}}/sdk/python/bin/dist
111+
- if: ${{ matrix.language == 'nodejs' && env.PUBLISH_NPM == 'true' }}
112+
uses: JS-DevTools/npm-publish@v1
113+
with:
114+
access: "public"
115+
token: ${{ env.NPM_TOKEN }}
116+
package: ${{github.workspace}}/sdk/nodejs/bin/package.json
117+
- if: ${{ matrix.language == 'dotnet' && env.PUBLISH_NUGET == 'true' }}
118+
name: publish nuget package
119+
run: |
120+
dotnet nuget push ${{github.workspace}}/sdk/dotnet/bin/Debug/*.nupkg -s ${{ env.NUGET_FEED_URL }} -k ${{ env.NUGET_PUBLISH_KEY }}
121+
echo "done publishing packages"
122+
strategy:
123+
fail-fast: true
124+
matrix:
125+
dotnetversion:
126+
- 6.0.113
127+
goversion:
128+
- 1.19.x
129+
language:
130+
- nodejs
131+
- python
132+
- dotnet
133+
- go
134+
nodeversion:
135+
- 18.x
136+
pythonversion:
137+
- "3.10"

.goreleaser.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
archives:
2+
- id: archive
3+
name_template: '{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}'
4+
before:
5+
hooks:
6+
- make tfgen
7+
builds:
8+
- binary: pulumi-resource-netbox
9+
dir: provider
10+
env:
11+
- CGO_ENABLED=0
12+
goarch:
13+
- amd64
14+
- arm64
15+
goos:
16+
- darwin
17+
- windows
18+
- linux
19+
ldflags:
20+
# The line below MUST align with the module in current provider/go.mod
21+
- -X github.com/hbjydev/pulumi-netbox/provider/pkg/version.Version={{.Tag }}
22+
main: ./cmd/pulumi-resource-netbox/
23+
changelog:
24+
skip: true
25+
release:
26+
disable: false
27+
prerelease: auto
28+
snapshot:
29+
name_template: '{{ .Tag }}-SNAPSHOT'

0 commit comments

Comments
 (0)