Skip to content

Commit

Permalink
TMP CI
Browse files Browse the repository at this point in the history
  • Loading branch information
apaillier-ledger committed Feb 6, 2025
1 parent d2e4f25 commit 37a453b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 97 deletions.
104 changes: 9 additions & 95 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,6 @@ env:
BUILD_PLATFORMS: linux/amd64,linux/arm64

jobs:
check_changelog:
name: Check changelog versions
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3

- name: Get current version
id: get-current-version
run: |
echo "current_version=$(grep -Po '(?<=## \[)(\d+\.)+[^\]]' CHANGELOG.md | head -n 1)" >> "$GITHUB_OUTPUT"
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Check already existing image
run: |
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
# Get tags of all images from GHCR
TAGS_FULL=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}/tags/list)
TAGS_LITE=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}-lite/tags/list)
TAGS_LEGACY=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}-legacy/tags/list)
TAGS_DEV_TOOLS=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/ledger-app-dev-tools/tags/list)
# Concatenate all tags from json fields in one string without brackets
ALL_TAGS=$(echo $TAGS_FULL $TAGS_LITE $TAGS_LEGACY $TAGS_DEV_TOOLS | jq -s '.[0].tags + .[1].tags + .[2].tags + .[3].tags' | tr -d '[]')
# Get the tag to find
TAG_TO_FIND=${{ steps.get-current-version.outputs.current_version }}
# Check if the tag to find is already present in the list of tags
if [[ "$ALL_TAGS" == *"$TAG_TO_FIND"* ]]; then
echo "An image tagged with the latest changelog version already exists on GHCR. Please update the changelog."
exit 1
else
exit 0
fi
outputs:
current_version: ${{ steps.get-current-version.outputs.current_version }}


mods_list:
name: Get modified files
runs-on: ubuntu-latest
Expand All @@ -77,8 +31,7 @@ jobs:
builder_lite:
name: App Builder Lite
runs-on: ubuntu-latest
needs: [mods_list, check_changelog]
if: needs.check_changelog.result == 'success' && contains(needs.mods_list.outputs.modified_files, 'lite/Dockerfile')
needs: [mods_list]
permissions:
packages: write

Expand Down Expand Up @@ -114,52 +67,14 @@ jobs:
with:
file: lite/Dockerfile
platforms: ${{ env.BUILD_PLATFORMS }}
tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ needs.check_changelog.outputs.current_version }}
labels: ${{ steps.meta.outputs.labels }}
push: false

builder_legacy:
name: App Builder Legacy
runs-on: ubuntu-latest
needs: [mods_list, check_changelog, builder_lite]
if: always() && needs.check_changelog.result == 'success' && (needs.builder_lite.result == 'success' || (needs.builder_lite.result == 'skipped' && contains(needs.mods_list.outputs.modified_files, 'legacy/Dockerfile')))
permissions:
packages: write

steps:
- name: Clone
uses: actions/checkout@v3

- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Make full image name
run: |
echo "IMAGE=${REGISTRY}/${REPO_PATH,,}/${REPO_NAME,,}-legacy" >>${GITHUB_ENV}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE }}

- name: Build and push container
uses: docker/build-push-action@v3
with:
file: legacy/Dockerfile
tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ needs.check_changelog.outputs.current_version }}
tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest
labels: ${{ steps.meta.outputs.labels }}
push: false
push: true

builder:
name: App Builder
runs-on: ubuntu-latest
needs: [mods_list, check_changelog, builder_lite]
if: always() && needs.check_changelog.result == 'success' && (needs.builder_lite.result == 'success' || (needs.builder_lite.result == 'skipped' && contains(needs.mods_list.outputs.modified_files, 'full/Dockerfile')))
needs: [mods_list, builder_lite]
permissions:
packages: write

Expand Down Expand Up @@ -195,15 +110,14 @@ jobs:
with:
file: full/Dockerfile
platforms: ${{ env.BUILD_PLATFORMS }}
tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ needs.check_changelog.outputs.current_version }}
tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest
labels: ${{ steps.meta.outputs.labels }}
push: false
push: true

dev_tools:
name: App Developer Tools
runs-on: ubuntu-latest
needs: [mods_list, check_changelog, builder]
if: always() && needs.check_changelog.result == 'success' && (needs.builder.result == 'success' || (needs.builder.result == 'skipped' && contains(needs.mods_list.outputs.modified_files, 'dev-tools/Dockerfile')))
needs: [mods_list, builder]
permissions:
packages: write

Expand Down Expand Up @@ -239,6 +153,6 @@ jobs:
with:
file: dev-tools/Dockerfile
platforms: ${{ env.BUILD_PLATFORMS }}
tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ needs.check_changelog.outputs.current_version }}
tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest
labels: ${{ steps.meta.outputs.labels }}
push: false
push: true
2 changes: 1 addition & 1 deletion dev-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
FROM ghcr.io/apaillier-ledger/ledger-app-builder/ledger-app-builder:latest

RUN apt install -y --no-install-recommends \
imagemagick \
Expand Down
2 changes: 1 addition & 1 deletion full/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest
FROM ghcr.io/apaillier-ledger/ledger-app-builder/ledger-app-builder-lite:latest

ENV RUST_STABLE=1.83.0
ENV RUST_NIGHTLY=nightly-2024-12-01
Expand Down

0 comments on commit 37a453b

Please sign in to comment.