github.com/oam-dev/cluster-gateway@v1.9.0/.github/workflows/go-release.yml (about) 1 name: GoRelease 2 3 on: 4 push: 5 tags: 6 - 'v*' 7 env: 8 # Common versions 9 GO_VERSION: '1.20' 10 GO_REQUIRED_MIN_VERSION: '' 11 GOPATH: '/home/runner/work/oamdev/cluster-gateway/go' 12 GITHUB_REF: ${{ github.ref }} 13 14 defaults: 15 run: 16 working-directory: go/src/oamdev/cluster-gateway 17 18 jobs: 19 env: 20 name: prepare release env 21 runs-on: ubuntu-latest 22 steps: 23 - name: checkout code 24 uses: actions/checkout@v2 25 with: 26 fetch-depth: 1 27 path: go/src/oamdev/cluster-gateway 28 - name: get release version 29 run: | 30 echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV 31 - name: get major release version 32 run: | 33 echo "MAJOR_RELEASE_VERSION=${RELEASE_VERSION%.*}" >> $GITHUB_ENV 34 echo "TRIMED_RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV 35 - name: verify chart version 36 run: | 37 sed -i 's/version: 0.1.0/version: ${{ env.TRIMED_RELEASE_VERSION }}/g' ./charts/cluster-gateway/Chart.yaml 38 sed -i 's/version: 0.1.0/version: ${{ env.TRIMED_RELEASE_VERSION }}/g' ./charts/addon-manager/Chart.yaml 39 cat ./charts/cluster-gateway/Chart.yaml | grep -q 'version: ${{ env.TRIMED_RELEASE_VERSION }}' 40 cat ./charts/addon-manager/Chart.yaml | grep -q 'version: ${{ env.TRIMED_RELEASE_VERSION }}' 41 outputs: 42 RELEASE_VERSION: ${{ env.RELEASE_VERSION }} 43 TRIMED_RELEASE_VERSION: ${{ env.TRIMED_RELEASE_VERSION }} 44 image-multi-arch: 45 name: multi arch image build 46 runs-on: ubuntu-latest 47 needs: [ env ] 48 strategy: 49 matrix: 50 arch: [ amd64, arm64 ] 51 steps: 52 - name: checkout code 53 uses: actions/checkout@v2 54 with: 55 fetch-depth: 1 56 path: go/src/oamdev/cluster-gateway 57 - name: install Go 58 uses: actions/setup-go@v2 59 with: 60 go-version: ${{ env.GO_VERSION }} 61 - name: images multi arch 62 run: | 63 IMG_TAG=${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} \ 64 OS=linux \ 65 ARCH=${{ matrix.arch }} \ 66 make image 67 - name: Login docker.io 68 uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 69 with: 70 registry: docker.io 71 username: ${{ secrets.DOCKER_USER }} 72 password: ${{ secrets.DOCKER_PASSWORD }} 73 - name: push image multi arch 74 run: | 75 docker push oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} 76 docker push oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} 77 image-manifest: 78 name: image-manifest 79 runs-on: ubuntu-latest 80 needs: [ env, image-multi-arch ] 81 steps: 82 - name: checkout code 83 uses: actions/checkout@v2 84 with: 85 fetch-depth: 1 86 path: go/src/oamdev/cluster-gateway 87 - name: Login docker.io 88 uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 89 with: 90 registry: docker.io 91 username: ${{ secrets.DOCKER_USER }} 92 password: ${{ secrets.DOCKER_PASSWORD }} 93 - name: create 94 run: | 95 docker manifest create oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \ 96 oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \ 97 oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 98 docker manifest create oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \ 99 oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \ 100 oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 101 - name: annotate 102 run: | 103 docker manifest annotate oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \ 104 oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64 105 docker manifest annotate oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \ 106 oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64 107 docker manifest annotate oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \ 108 oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64 109 docker manifest annotate oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \ 110 oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64 111 - name: push 112 run: | 113 docker manifest push oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} 114 docker manifest push oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} 115 release: 116 name: release 117 runs-on: ubuntu-latest 118 needs: [ env, image-manifest ] 119 steps: 120 - name: checkout code 121 uses: actions/checkout@v2 122 with: 123 fetch-depth: 1 124 path: go/src/oamdev/cluster-gateway 125 - name: setup helm 126 uses: azure/setup-helm@v1 127 - name: chart package 128 run: | 129 mkdir -p release 130 pushd release 131 helm package ../charts/cluster-gateway/ 132 helm package ../charts/addon-manager/ 133 popd 134 - name: publish release 135 uses: ncipollo/release-action@v1 136 with: 137 tag: ${{ needs.env.outputs.RELEASE_VERSION }} 138 artifacts: "go/src/oamdev/cluster-gateway/release/*.tgz" 139 token: ${{ secrets.GITHUB_TOKEN }} 140 allowUpdates: true 141 # lack secrets.PAT_TOKEN from ocm, commented now 142 # - name: submit charts to OCM chart repo 143 # uses: actions/github-script@v6 144 # with: 145 # debug: ${{ secrets.ACTIONS_RUNNER_DEBUG }} 146 # github-token: ${{ secrets.PAT_TOKEN }} 147 # script: | 148 # try { 149 # const result = await github.rest.actions.createWorkflowDispatch({ 150 # owner: 'open-cluster-management-io', 151 # repo: 'helm-charts', 152 # workflow_id: 'download-chart.yml', 153 # ref: 'main', 154 # inputs: { 155 # repo: "${{ github.repository }}", 156 # version: "${{ needs.env.outputs.TRIMED_RELEASE_VERSION }}", 157 # "chart-name": "cluster-gateway-addon-manager", 158 # }, 159 # }) 160 # console.log(result); 161 # } catch(error) { 162 # console.error(error); 163 # core.setFailed(error); 164 # }