Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
73 changes: 73 additions & 0 deletions .github/workflows/tag_latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Ethrex Latest Release

on:
release:
types:
- edited

permissions:
contents: read
packages: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
get_latest_release:
name: "Get latest release tag"
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.get_latest_release.outputs.latest_tag }}

steps:
- name: Get latest release tag from GH API
id: get_latest_release
run: |
tag=$(curl -s https://api.github.com/repos/${{ env.IMAGE_NAME }}/releases/latest | jq -r .tag_name)
echo "Latest release tag: $tag"
echo "latest_tag=$tag" >> $GITHUB_OUTPUT
retag_docker_images:
name: "Tag latest Docker images"
runs-on: ubuntu-latest
needs: [get_latest_release]
if: ${{ needs.get_latest_release.outputs.latest_tag == github.event.release.tag_name }}

# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Set tags
run: |
echo "PREV_TAG=$(echo ${{ github.event.changes.tag_name.from }} | tr -d v)" >> $GITHUB_ENV
echo "NEW_TAG=$(echo ${{ github.event.release.tag_name }} | tr -d v)" >> $GITHUB_ENV
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2

Check failure on line 50 in .github/workflows/tag_latest.yaml

View workflow job for this annotation

GitHub Actions / Lint

the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download Docker images
run: |
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}-l2
- name: Retag Docker images
run: |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}-l2 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:l2
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}-l2 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}-l2
- name: Push retagged Docker images
run: |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}-l2
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:l2
32 changes: 10 additions & 22 deletions .github/workflows/tag_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Ethrex Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-*"
- "v*.*.*-*"

permissions:
contents: write
Expand Down Expand Up @@ -198,16 +197,6 @@ jobs:
run: |
echo "TAG_VERSION=$(echo ${{ github.ref_name }} | tr -d v)" >> $GITHUB_ENV

- name: Select tags
run: |
if [ "$(echo ${{ github.ref_name }}- | cut -d- -f2 | grep '^rc')" == "" ]; then
echo "L1_TAGS=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}" >> $GITHUB_ENV
echo "L2_TAGS=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:l2,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}-l2" >> $GITHUB_ENV
else
echo "L1_TAGS=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}" >> $GITHUB_ENV
echo "L2_TAGS=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}-l2" >> $GITHUB_ENV
fi

# Pushes to ghcr.io/lambdaclass/ethrex
- name: Build and push L1 Docker image
id: push_l1
Expand All @@ -217,7 +206,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
push: true
tags: ${{ env.L1_TAGS }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}

# Pushes to ghcr.io/lambdaclass/ethrex
- name: Build and push L2 Docker image
Expand All @@ -228,7 +217,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
push: true
tags: ${{ env.L2_TAGS }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}-l2
build_args: BUILD_FLAGS=--features l2,l2-sql

# Creates a release on GitHub with the binaries
Expand All @@ -252,12 +241,11 @@ jobs:

- name: Get previous tag
run: |
name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1)
echo "PREVIOUS_TAG: $name"
echo "PREVIOUS_TAG=$name" >> $GITHUB_ENV

- name: Check release type
run: echo "TAG_SUFFIX=$(echo ${{ github.ref_name }}- | cut -d- -f2)" >> $GITHUB_ENV
last_tag=$(git --no-pager tag --sort=creatordate | grep -v -E '^v[0-9]+\.[0-9]+\.[0-9]+-' | grep -v '${{ github.ref_name }}' | tail -1)
echo "Last tag: $last_tag"
common_parent=$(git merge-base ${{ github.ref_name }} $last_tag)
echo "PREVIOUS_TAG: $common_parent"
echo "PREVIOUS_TAG=$common_parent" >> $GITHUB_ENV

- name: Update CHANGELOG
id: changelog
Expand All @@ -274,8 +262,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ./bin/**/*
draft: ${{ startsWith(env.TAG_SUFFIX, 'rc') }}
prerelease: ${{ startsWith(env.TAG_SUFFIX, 'rc') }}
draft: false
prerelease: true
tag_name: ${{ github.ref_name }}
name: "ethrex: ${{ github.ref_name }}"
body: >
Expand Down
Loading