Skip to content

feat: support for dynamically fetching credentials from external comm… #44

feat: support for dynamically fetching credentials from external comm…

feat: support for dynamically fetching credentials from external comm… #44

Workflow file for this run

name: GoRelease
on:
push:
tags:
- 'v*'
env:
# Common versions
GO_VERSION: '1.20'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/oamdev/cluster-gateway/go'
GITHUB_REF: ${{ github.ref }}
defaults:
run:
working-directory: go/src/oamdev/cluster-gateway
jobs:
env:
name: prepare release env
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- name: get release version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: get major release version
run: |
echo "MAJOR_RELEASE_VERSION=${RELEASE_VERSION%.*}" >> $GITHUB_ENV
echo "TRIMED_RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV
- name: verify chart version
run: |
sed -i 's/version: 0.1.0/version: ${{ env.TRIMED_RELEASE_VERSION }}/g' ./charts/cluster-gateway/Chart.yaml
sed -i 's/version: 0.1.0/version: ${{ env.TRIMED_RELEASE_VERSION }}/g' ./charts/addon-manager/Chart.yaml
cat ./charts/cluster-gateway/Chart.yaml | grep -q 'version: ${{ env.TRIMED_RELEASE_VERSION }}'
cat ./charts/addon-manager/Chart.yaml | grep -q 'version: ${{ env.TRIMED_RELEASE_VERSION }}'
outputs:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
TRIMED_RELEASE_VERSION: ${{ env.TRIMED_RELEASE_VERSION }}
image-multi-arch:
name: multi arch image build
runs-on: ubuntu-latest
needs: [ env ]
strategy:
matrix:
arch: [ amd64, arm64 ]
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- name: install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: images multi arch
run: |
IMG_TAG=${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} \
OS=linux \
ARCH=${{ matrix.arch }} \
make image
- name: Login docker.io
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: push image multi arch
run: |
docker push oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
docker push oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
image-manifest:
name: image-manifest
runs-on: ubuntu-latest
needs: [ env, image-multi-arch ]
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- name: Login docker.io
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: create
run: |
docker manifest create oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-arm64
docker manifest create oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \
oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64
- name: annotate
run: |
docker manifest annotate oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64
docker manifest annotate oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64
docker manifest annotate oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64
docker manifest annotate oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64
- name: push
run: |
docker manifest push oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}
docker manifest push oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}
release:
name: release
runs-on: ubuntu-latest
needs: [ env, image-manifest ]
steps:
- name: checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- name: setup helm
uses: azure/setup-helm@v1
- name: chart package
run: |
mkdir -p release
pushd release
helm package ../charts/cluster-gateway/
helm package ../charts/addon-manager/
popd
- name: publish release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.env.outputs.RELEASE_VERSION }}
artifacts: "go/src/oamdev/cluster-gateway/release/*.tgz"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
# lack secrets.PAT_TOKEN from ocm, commented now
# - name: submit charts to OCM chart repo
# uses: actions/github-script@v6
# with:
# debug: ${{ secrets.ACTIONS_RUNNER_DEBUG }}
# github-token: ${{ secrets.PAT_TOKEN }}
# script: |
# try {
# const result = await github.rest.actions.createWorkflowDispatch({
# owner: 'open-cluster-management-io',
# repo: 'helm-charts',
# workflow_id: 'download-chart.yml',
# ref: 'main',
# inputs: {
# repo: "${{ github.repository }}",
# version: "${{ needs.env.outputs.TRIMED_RELEASE_VERSION }}",
# "chart-name": "cluster-gateway-addon-manager",
# },
# })
# console.log(result);
# } catch(error) {
# console.error(error);
# core.setFailed(error);
# }