|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: 'v*' |
| 5 | + |
| 6 | +# Needed to create the release |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + id-token: write |
| 10 | + |
| 11 | +# Needed to create the release and use gh cli |
| 12 | +env: |
| 13 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 14 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + create-release: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout Code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + - name: Create a Release |
| 23 | + id: create_release |
| 24 | + uses: actions/create-release@v1 |
| 25 | + with: |
| 26 | + tag_name: ${{ github.ref }} |
| 27 | + release_name: Release ${{ github.ref_name }} |
| 28 | + prerelease: true |
| 29 | + |
| 30 | + build-and-push-amd64: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + needs: [create-release] |
| 33 | + steps: |
| 34 | + - name: Checkout Code |
| 35 | + uses: actions/checkout@v4 |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v3 |
| 38 | + with: |
| 39 | + buildkitd-flags: --debug |
| 40 | + - name: Set up QEMU |
| 41 | + uses: docker/setup-qemu-action@v3 |
| 42 | + - name: Run Dapper CI |
| 43 | + run: make ci |
| 44 | + - name: Generate Checksum |
| 45 | + run: | |
| 46 | + cd dist/artifacts |
| 47 | + sha256sum * > sha256sum-amd64.txt |
| 48 | + - name: Upload Assets |
| 49 | + run: | |
| 50 | + ASSETS_DIR="dist/artifacts" |
| 51 | + TAG=${{ github.ref_name }} |
| 52 | + for file in $ASSETS_DIR/*; do |
| 53 | + gh release upload $TAG $file --repo ${{ github.repository }} |
| 54 | + done |
| 55 | + - name: Build Manifest |
| 56 | + id: metadata |
| 57 | + uses: docker/metadata-action@v5 |
| 58 | + with: |
| 59 | + images: | |
| 60 | + docker.io/rancher/rancher-csp-adapter |
| 61 | + 709825985650.dkr.ecr.us-east-1.amazonaws.com/suse/rancher/rancher-csp-adapter |
| 62 | + flavor: | |
| 63 | + latest=false |
| 64 | + - name: Read Secrets |
| 65 | + uses: rancher-eio/read-vault-secrets@main |
| 66 | + with: |
| 67 | + secrets: | |
| 68 | + secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ; |
| 69 | + secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ; |
| 70 | + secret/data/github/repo/${{ github.repository }}/aws/aws-rancher-csp-adapter-ecr/credentials accessKeyId | ECR_ACCESS_KEY ; |
| 71 | + secret/data/github/repo/${{ github.repository }}/aws/aws-rancher-csp-adapter-ecr/credentials secretAccessKey | ECR_SECRET_KEY ; |
| 72 | + secret/data/github/repo/${{ github.repository }}/aws/aws-rancher-csp-adapter-ecr-eu/credentials accessKeyId | ECR_ACCESS_KEY_EU ; |
| 73 | + secret/data/github/repo/${{ github.repository }}/aws/aws-rancher-csp-adapter-ecr-eu/credentials secretAccessKey | ECR_SECRET_KEY_EU ; |
| 74 | + - name: Login to Docker Registry |
| 75 | + uses: docker/login-action@v3 |
| 76 | + with: |
| 77 | + username: ${{ env.DOCKER_USERNAME }} |
| 78 | + password: ${{ env.DOCKER_PASSWORD }} |
| 79 | + - name: Configure AWS credentials |
| 80 | + uses: aws-actions/configure-aws-credentials@v4 |
| 81 | + with: |
| 82 | + aws-access-key-id: ${{ env.ECR_ACCESS_KEY }} |
| 83 | + aws-secret-access-key: ${{ env.ECR_SECRET_KEY }} |
| 84 | + aws-region: us-east-1 |
| 85 | + - name: Login to ECR |
| 86 | + uses: docker/login-action@v2 |
| 87 | + with: |
| 88 | + registry: 709825985650.dkr.ecr.us-east-1.amazonaws.com |
| 89 | + - name: Push Images to Registries |
| 90 | + uses: docker/build-push-action@v5 |
| 91 | + with: |
| 92 | + context: . |
| 93 | + push: true |
| 94 | + tags: ${{ steps.metadata.outputs.tags }} |
| 95 | + labels: ${{ steps.metadata.outputs.labels }} |
| 96 | + file: package/Dockerfile |
| 97 | + platforms: linux/amd64 |
| 98 | + - name: Build Manifest for EU Registry Images |
| 99 | + id: metadata_eu |
| 100 | + uses: docker/metadata-action@v5 |
| 101 | + with: |
| 102 | + images: | |
| 103 | + 709825985650.dkr.ecr.us-east-1.amazonaws.com/suse/rancher/rancher-csp-adapter-eu |
| 104 | + flavor: | |
| 105 | + latest=false |
| 106 | + - name: Configure AWS credentials for EU Registry |
| 107 | + uses: aws-actions/configure-aws-credentials@v4 |
| 108 | + with: |
| 109 | + aws-access-key-id: ${{ env.ECR_ACCESS_KEY_EU }} |
| 110 | + aws-secret-access-key: ${{ env.ECR_SECRET_KEY_EU }} |
| 111 | + aws-region: us-east-1 |
| 112 | + - name: Login to ECR for EU Registry |
| 113 | + uses: docker/login-action@v2 |
| 114 | + with: |
| 115 | + registry: 709825985650.dkr.ecr.us-east-1.amazonaws.com |
| 116 | + - name: Push Images to EU Registry |
| 117 | + uses: docker/build-push-action@v5 |
| 118 | + with: |
| 119 | + context: . |
| 120 | + push: true |
| 121 | + tags: ${{ steps.metadata_eu.outputs.tags }} |
| 122 | + labels: ${{ steps.metadata_eu.outputs.labels }} |
| 123 | + file: package/Dockerfile |
| 124 | + platforms: linux/amd64 |
0 commit comments