Skip to content

ci: Refactor stable.yml #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 37 additions & 44 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,29 @@ env:
REGISTRY_IMAGE: clux/muslrust

jobs:
check-stable:
name: 'Check if workflow should continue'
outputs:
CONTINUE_BUILD: ${{ steps.check-stable-tag.outputs.CONTINUE_BUILD }}
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- name: 'Check if we need a new stable'
id: check-stable-tag
shell: bash
run: |
pip3 install --user toml
if python3 check_stable.py; then
echo 'Stable tag missing; running all build steps'
echo 'CONTINUE_BUILD=YES' >> "${GITHUB_OUTPUT}"
else
echo 'Stable tag found; skipping all build steps'
fi

build:
name: 'Stable Build'
needs: [check-stable]
if: ${{ needs.check-stable.outputs.CONTINUE_BUILD == 'YES' }}
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
Expand All @@ -41,23 +62,6 @@ jobs:
username: clux
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Check if we need a new stable
id: stablecheck
shell: bash
run: |
pip3 install --user toml
if python3 check_stable.py; then
echo "Stable tag missing; running all build steps"
echo "BUILD=YES" >> $GITHUB_OUTPUT
else
echo "Stable tag found; skipping all build steps"
fi

- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
Comment on lines -55 to -59
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this was probably from some older experiments iirc.


- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand All @@ -82,10 +86,8 @@ jobs:
tags: rustmusl-temp
build-args: |
CHANNEL=stable
if: ${{ steps.stablecheck.outputs.BUILD }}

- name: Run tests
if: ${{ steps.stablecheck.outputs.BUILD }}
shell: bash
run: |
docker buildx build --platform ${{ matrix.platform }} --output type=docker -t test-runner - < Dockerfile.test-runner
Expand All @@ -98,7 +100,6 @@ jobs:
# only identifiable by their digest and it appears docker does not let us select an image that way.
# Not the most elegant, but it works.
- name: Store tag info
if: ${{ steps.stablecheck.outputs.BUILD }}
shell: bash
run: |
mkdir -p /tmp/tags
Expand All @@ -111,7 +112,6 @@ jobs:
echo $RUST_VER > /tmp/tags/rust-ver

- name: Tag and push
if: ${{ steps.stablecheck.outputs.BUILD }}
shell: bash
run: |
RUST_DATE=$(cat /tmp/tags/rust-date)
Expand All @@ -125,15 +125,13 @@ jobs:

# TODO: want to do this, but need digest, which might not be trivial to get outside build-push-action
# - name: Attest docker.io
# if: ${{ steps.stablecheck.outputs.BUILD }}
# uses: actions/[email protected]
# with:
# subject-name: docker.io/${{ env.REGISTRY_IMAGE }}
# subject-digest: ${{ steps.push_stable.outputs.digest }}
# push-to-registry: true

- name: Upload tags
if: ${{ steps.stablecheck.outputs.BUILD }}
uses: actions/upload-artifact@v4
with:
name: tags-${{matrix.arch}}
Expand All @@ -148,21 +146,7 @@ jobs:
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Check if we need a new stable
id: stablecheck
shell: bash
run: |
pip3 install --user toml
if python3 check_stable.py; then
echo "Stable tag missing; running all build steps"
echo "BUILD=YES" >> $GITHUB_OUTPUT
else
echo "Stable tag found; skipping all build steps"
fi

- name: Download tags
if: ${{ steps.stablecheck.outputs.BUILD }}
uses: actions/download-artifact@v4
with:
path: /tmp/tags
Expand All @@ -185,19 +169,28 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create manifest list and push multi-platform images
if: ${{ steps.stablecheck.outputs.BUILD }}
shell: bash
run: |
RUST_DATE=$(cat /tmp/tags/rust-date)
RUST_CHANNEL=$(cat /tmp/tags/rust-channel)
RUST_VER=$(cat /tmp/tags/rust-ver)

for tag in ${RUST_CHANNEL} ${RUST_CHANNEL}-${RUST_DATE} ${RUST_VER}-${RUST_CHANNEL} ${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE}; do
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:$tag \
${{ env.REGISTRY_IMAGE }}:amd64-${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE} \
${{ env.REGISTRY_IMAGE }}:arm64-${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE}
done
# The two already published image tags to associate additional tags to:
AMD64="${{ env.REGISTRY_IMAGE }}:amd64-${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE}"
ARM64="${{ env.REGISTRY_IMAGE }}:arm64-${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE}"

EXTRA_TAGS=(
"${RUST_CHANNEL}"
"${RUST_CHANNEL}-${RUST_DATE}"
"${RUST_VER}-${RUST_CHANNEL}"
"${RUST_VER}-${RUST_CHANNEL}-${RUST_DATE}"
)

# Assign each tag to the two source image tags:
for TAG in "${EXTRA_TAGS[@]}"; do
docker buildx imagetools create --tag "${{ env.REGISTRY_IMAGE }}:${TAG}" "${AMD64}" "${ARM64}"
done

- name: Inspect image
if: ${{ steps.stablecheck.outputs.BUILD }}
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest
Loading