Skip to content

Create release on new release from upstream #650

Create release on new release from upstream

Create release on new release from upstream #650

Workflow file for this run

name: Create release on new release from upstream
on:
schedule:
- cron: '0 1 * * *' # Every day at 01:00
workflow_dispatch:
jobs:
check_release:
name: Check last release
runs-on: ubuntu-latest
steps:
- name: Install curl and jq
run: sudo apt update && sudo apt install -y curl jq
- name: Get latest DNS Proxy tag
run: echo "TAG_NAME=$(curl https://api.github.com/repos/AdguardTeam/dnsproxy/releases/latest | jq -r '.tag_name')" >> $GITHUB_ENV
- name: Check if tag already exists
uses: mukunku/tag-exists-action@v1.6.0
id: checkTag
with:
tag: ${{ env.TAG_NAME }}
outputs:
tag_already_exists: ${{ steps.checkTag.outputs.exists }}
tag: ${{ env.TAG_NAME }}
publish_docker:
name: Publish on Docker Hub
needs:
- check_release
if: needs.check_release.outputs.tag_already_exists == 'false'
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
axeleroy/dnsproxy
ghcr.io/axeleroy/dnsproxy
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
build-args: dnsproxy_version=${{ needs.check_release.outputs.tag }}
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7,linux/386,linux/ppc64le,linux/s390x
tags: >
axeleroy/dnsproxy:latest,
axeleroy/dnsproxy:${{ needs.check_release.outputs.tag }},
ghcr.io/axeleroy/dnsproxy:latest,
ghcr.io/axeleroy/dnsproxy:${{ needs.check_release.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}
# See https://docs.docker.com/build/ci/github-actions/examples/#github-cache
cache-from: type=gha
cache-to: type=gha,mode=max
create_release:
name: Create release
needs:
- check_release
- publish_docker
if: needs.check_release.outputs.tag_already_exists == 'false'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Install curl and jq
run: sudo apt update && sudo apt install -y curl jq
- name: Get original release's body and title
run: |
RELEASE=$(curl https://api.github.com/repos/AdguardTeam/dnsproxy/releases | jq '.[] | select(.tag_name == "${{ needs.check_release.outputs.tag }}")')
echo "RELEASE_NAME=$(echo "$RELEASE" | jq -r '.name')" >> $GITHUB_ENV
echo "$RELEASE" | jq -r '(.body + "\n---\nOriginal release: " + .html_url)' > release_body.md
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.RELEASE_NAME }}
body_path: release_body.md
tag_name: ${{ needs.check_release.outputs.tag }}