Skip to content

Commit

Permalink
[v2.9] fix tag workflows (rancher#46244)
Browse files Browse the repository at this point in the history
* preserve env

* use sudo to move home bin

* use github sha as default tag

* remove sudo fromo create components images files

* set tag on push

* preserver env

* define bash

* use sudo to move files

* use sudo to generate hashes

* fix docker image digests

* fix image name

* fix windows images

* update file permissions

* remove sudo from artifacts creation
  • Loading branch information
tashima42 authored Jul 19, 2024
1 parent 76fc7f0 commit 3826b70
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .github/actions/setup-tag-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ runs:
- shell: bash
run: |
ref_name="${{ github.ref_name }}"
TAG="${ref_name}"
TAG="${{ github.sha }}"
prefix="release/"
if [[ "$ref_name" == release/v* ]]; then
TAG=${ref_name#$prefix}-${{ github.sha }}-head
HEAD_TAG=${ref_name#$prefix}-head
echo "HEAD_TAG=$HEAD_TAG" >> "$GITHUB_ENV"
fi
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG="$ref_name"
fi
echo "TAG=$TAG" >> "$GITHUB_ENV"
echo "GIT_TAG=$TAG" >> "$GITHUB_ENV"
3 changes: 2 additions & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ env:
GOLANG_VERSION: '1.22'
IMAGE: ${{ github.repository_owner }}/rancher
IMAGE_AGENT: ${{ github.repository_owner }}/rancher-agent
TAG: ${{ github.sha }}
jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -34,6 +33,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Environment Variables
uses: ./.github/actions/setup-tag-env
- name: Clean up Docker
run: |
docker system prune -af
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/push-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ jobs:
CLOUDSDK_AUTH_ACCESS_TOKEN=${{ env.GOOGLE_AUTH }} gcloud storage cp /tmp/charts gs://releases.rancher.com/server-charts --recursive --acl allUsers:READER --cache-control "public,no-cache,proxy-revalidate"
build-server:
runs-on: ubuntu-latest
needs: [unit-tests]
strategy:
matrix:
os: [linux]
Expand Down Expand Up @@ -262,7 +261,7 @@ jobs:
shell: bash
push-images:
runs-on: ubuntu-latest
needs: [integration-tests]
needs: [unit-tests, integration-tests]
permissions:
contents: read
id-token: write
Expand Down Expand Up @@ -505,21 +504,22 @@ jobs:
mkdir -p $HOME/bin
touch $HOME/bin/rancher-rke-k8s-versions.txt
- name: Create components and images files
run: sudo -E ./scripts/create-components-images-files.sh
shell: bash
run: ./scripts/create-components-images-files.sh
- name: Move files
run: |
mv $HOME/bin/* ./dist
mv ./bin/*.txt ./dist
mv ./bin/*.sh ./dist
mv ./bin/*.ps1 ./dist
- name: Create sha256sum.txt file
run: ./scripts/artifacts-hashes.sh
run: bash ./scripts/artifacts-hashes.sh
- name: Upload artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload -R ${{ env.REPOSITORY_OWNER }}/rancher ${{ env.TAG }} ./dist/* --clobber
docker-image-digests:
if: github.event_name == 'tag' && contains(github.ref, 'tags/') # Only run on tag
if: github.event_name == 'push' && contains(github.ref, 'tags/') # Only run on tag
runs-on: ubuntu-latest
needs: [create-images-files]
env:
Expand All @@ -542,17 +542,17 @@ jobs:
mkdir -p /tmp/digests
- name: Generate Linux Digests
run: |
export LINUX_IMAGES_URL=https://github.com/${{ github.repository_owner }}/${{ github.repository }}/releases/download/${{ env.TAG}}/rancher-images.txt
export LINUX_IMAGES_URL=https://github.com/${{ github.repository }}/releases/download/${{ env.TAG}}/rancher-images.txt
release generate rancher docker-images-digests \
--images-url "$LINUX_IMAGES_URL" \
--output-file /tmp/digests/rancher-images-digests-linux-amd64.txt \
--registry ${{ env.DOCKER_REGISTRY }}
cp /tmp/digests/rancher-images-digests-linux-amd64.txt /tmp/digests/rancher-images-digests-linux-arm64.txt
- name: Generate Windows Digests
run: |
export LINUX_IMAGES_URL=https://github.com/${{ github.repository_owner }}/${{ github.repository }}/releases/download/${{ env.TAG}}/rancher-images.txt
export WINDOWS_IMAGES_URL=https://github.com/${{ github.repository }}/releases/download/${{ env.TAG}}/rancher-windows-images.txt
release generate rancher docker-images-digests \
--images-url "$LINUX_IMAGES_URL" \
--images-url "$WINDOWS_IMAGES_URL" \
--output-file /tmp/digests/rancher-images-digests-windows-ltsc2019.txt \
--registry ${{ env.DOCKER_REGISTRY }}
cp /tmp/digests/rancher-images-digests-windows-ltsc2019.txt /tmp/digests/rancher-images-digests-windows-ltsc2022.txt
Expand Down
Empty file modified scripts/artifacts-hashes.sh
100644 → 100755
Empty file.
Empty file modified scripts/create-components-images-files.sh
100644 → 100755
Empty file.

0 comments on commit 3826b70

Please sign in to comment.