From 974f420c50021a4900c56cfabfae74d49b497128 Mon Sep 17 00:00:00 2001 From: Christophe Jauffret Date: Thu, 31 Mar 2022 13:11:33 +0200 Subject: [PATCH] implement build and releasea action --- .github/workflows/build-dev.yaml | 51 ++++++++++++++++++++++++- .github/workflows/release.yaml | 64 ++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build-dev.yaml b/.github/workflows/build-dev.yaml index 4dafacb072..c9e9dd079c 100644 --- a/.github/workflows/build-dev.yaml +++ b/.github/workflows/build-dev.yaml @@ -8,4 +8,53 @@ jobs: runs-on: ubuntu-latest steps: - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." \ No newline at end of file + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: '^1.17' + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: capi-nutanix + sep-tags: "," + sep-labels: "," + tags: | + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern=v{{major}} + type=sha + + - name: Install tools + uses: redhat-actions/openshift-tools-installer@v1 + with: + source: "github" + ko: "latest" + + - name: Prepare build + run: make test + + - name: Build container + env: + KO_DOCKER_REPO: ghcr.io/nutanix-cloud-native/cluster-api-provider-nutanix/controller + TAGS: ${{ steps.meta.outputs.tags }} + LABELS: ${{ steps.meta.outputs.labels }} + PLATFORMS: linux/amd64,linux/arm64,linux/arm + run: | + PTAGS=`echo $TAGS | sed 's/capi-nutanix://g'` + export SOURCE_DATE_EPOCH=$(date +%s) + ko build --bare --image-label "$LABELS" -t "$PTAGS" --platform=$PLATFORMS . + diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..eaac65c12d --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,64 @@ +name: Generate release artefact + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release_content: + name: Prepare Release release_content + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install tools + uses: redhat-actions/openshift-tools-installer@v1 + with: + source: "github" + kustomize: "latest" + + - name: build template + run: kustomize build config/default > infrastructure-components.yaml + + - name: release + uses: actions/create-release@v1 + id: create_release + with: + draft: false + prerelease: true + release_name: ${{ github.ref }} + tag_name: ${{ github.ref }} + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: upload infrastructure-components.yaml + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./infrastructure-components.yaml + asset_name: infrastructure-components.yaml + asset_content_type: application/yaml + + - name: upload metadata.yaml + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./metadata.yaml + asset_name: metadata.yaml + asset_content_type: application/yaml + + - name: upload cluster-template.yaml + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./cluster-template.yaml + asset_name: cluster-template.yaml + asset_content_type: application/yaml \ No newline at end of file