Merge pull request #599 from cprivitere/update-apt-sources #48
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# workflow to release assets as part of the release | |
name: Upload Release Asset | |
on: | |
push: | |
tags: | |
- 'v*' | |
env: | |
IMAGE_NAME: cluster-api-provider-packet | |
GHCR_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
DOCKER_REGISTRY: ${{ secrets.DOCKER_ORG }} | |
QUAY_REGISTRY: quay.io/${{ secrets.QUAY_ORG }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build-image: | |
name: Build and Push Image | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write # needed to push docker image to ghcr.io | |
steps: | |
- name: Checkout git repo | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to ghcr.io registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Log into DockerHub | |
uses: docker/login-action@v2 | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
if: ${{ env.DOCKER_USERNAME != '' }} | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log into quay.io | |
uses: docker/login-action@v2 | |
env: | |
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} | |
if: ${{ env.QUAY_USERNAME != '' }} | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ env.QUAY_REGISTRY }}/${{ env.IMAGE_NAME }} | |
${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }} | |
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }} | |
flavor: | | |
latest=auto | |
tags: | | |
type=semver,pattern={{version}} | |
type=ref,event=branch | |
type=ref,event=tag | |
type=ref,event=pr | |
type=sha | |
- name: Setup Env | |
run: | | |
DOCKER_BUILD_LDFLAGS="$(hack/version.sh)" | |
echo 'DOCKER_BUILD_LDFLAGS<<EOF' >> $GITHUB_ENV | |
echo $DOCKER_BUILD_LDFLAGS >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Docker Build and Push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
build-args: | | |
LDFLAGS=${{ env.DOCKER_BUILD_LDFLAGS }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64, linux/arm64, linux/arm/v7 | |
outputs: | |
image-tag: "${{ steps.docker_meta.outputs.version }}" | |
release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
needs: [build-image] | |
env: | |
TAG: ${{ needs.build-image.outputs.image-tag }} | |
REGISTRY: quay.io/${{ secrets.QUAY_ORG }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: './go.mod' | |
- name: Make Release | |
run: make release | |
- name: Generate Release Notes | |
run: | | |
release_notes=$(gh api repos/{owner}/{repo}/releases/generate-notes -F tag_name=${{ github.ref }} --jq .body) | |
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV | |
echo "${release_notes}" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
OWNER: ${{ github.repository_owner }} | |
REPO: ${{ github.event.repository.name }} | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: out/release/* | |
body: ${{ env.RELEASE_NOTES }} | |
draft: false | |
prerelease: false |