|
1 | | -# This is a basic workflow to help you get started with Actions |
2 | | - |
3 | 1 | name: Release |
4 | 2 |
|
5 | | -# Controls when the action will run. Triggers the workflow on push or pull request |
6 | | -# events but only for the master branch |
7 | 3 | on: |
8 | 4 | push: |
9 | 5 | tags: |
10 | | - - v*.*.* |
| 6 | + - "v[0-9]+.[0-9]+.[0-9]+*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + KUBEBUILDER_VERSION: 3.3.0 |
11 | 13 |
|
12 | 14 | jobs: |
13 | | - release: |
| 15 | + go-version: |
14 | 16 | runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + version: ${{ steps.go-version.outputs.version }} |
15 | 19 | steps: |
16 | | - - uses: actions/checkout@v2 |
17 | | - - name: Set up Go |
18 | | - uses: actions/setup-go@v1 |
19 | | - with: |
20 | | - go-version: 1.16.9 |
21 | | - - name: Install kubebuilder |
22 | | - run: | |
23 | | - curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_linux_amd64.tar.gz -o /tmp/kb.tgz |
24 | | - tar zxf /tmp/kb.tgz -C /tmp/ |
25 | | - - name: Run GoReleaser |
26 | | - uses: goreleaser/goreleaser-action@v2.8.0 |
27 | | - with: |
28 | | - args: release --skip-sign |
29 | | - env: |
30 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
31 | | - KUBEBUILDER_ASSETS: /tmp/kubebuilder_2.3.1_linux_amd64/bin/ |
32 | | - |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + - id: go-version |
| 22 | + run: echo "::set-output name=version::$(cat ./.go-version)" |
| 23 | + release-github: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v3 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + - name: Set up Go |
| 31 | + uses: actions/setup-go@v3 |
| 32 | + with: |
| 33 | + go-version: "${{ needs.go-version.outputs.version }}" |
| 34 | + - name: Install kubebuilder |
| 35 | + run: | |
| 36 | + curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{ env.KUBEBUILDER_VERSION }}/kubebuilder_${{ env.KUBEBUILDER_VERSION }}_linux_amd64.tar.gz -o /tmp/kb.tgz |
| 37 | + tar zxf /tmp/kb.tgz -C /tmp/ |
| 38 | + - name: Run GoReleaser |
| 39 | + uses: goreleaser/goreleaser-action@v3.0.0 |
| 40 | + if: startsWith(github.ref, 'refs/tags/') |
| 41 | + with: |
| 42 | + args: release --skip-sign |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + KUBEBUILDER_ASSETS: /tmp/kubebuilder_${{ env.KUBEBUILDER_VERSION }}_linux_amd64/bin/ |
| 46 | + release-docker-hub: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - name: Login to DockerHub |
| 50 | + uses: docker/login-action@v2 |
| 51 | + with: |
| 52 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 53 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 54 | + - name: Build and push |
| 55 | + uses: docker/build-push-action@v3 |
| 56 | + if: startsWith(github.ref, 'refs/tags/') |
| 57 | + with: |
| 58 | + push: false |
| 59 | + tags: hashicorp/terraform-k8s:${{ github.ref_name }} |
| 60 | + secrets: | |
| 61 | + GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} |
0 commit comments