1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00
dragonflydb-dragonfly/.github/workflows/docker-release.yml

114 lines
3.7 KiB
YAML
Raw Normal View History

2022-02-25 16:45:12 +00:00
name: docker release
on:
workflow_dispatch:
inputs:
TAG_NAME:
description: 'Tag name that the major tag will point to'
required: true
2022-06-06 15:32:11 +00:00
PRERELEASE:
description: 'Whether this is a prerelease'
type: boolean
required: true
release:
types: [published]
2022-02-25 16:45:12 +00:00
2022-05-11 17:37:25 +00:00
permissions:
packages: write
contents: write
id-token: write
2022-05-11 17:37:25 +00:00
env:
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
IS_PRERELEASE: ${{ github.event.release.prerelease || github.event.inputs.PRERELEASE }}
2022-02-25 16:45:12 +00:00
jobs:
# This workaround is needed, as it's not possible to reference env.FOOBAR directly at this stage
# - for ex. https://github.com/actions/runner/issues/1189
release-container-prereq:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.release-param.outputs.tag }}
tag_latest: ${{ steps.release-param.outputs.tag_latest }}
steps:
- id: release-param
run: |
# If env.IS_PRERELEASE is true, set tag to alpha and do not enable tag_latest
# If env.IS_PRERELEASE is not true (aka false), don't set an extra tag and enable tag_latest
echo "::set-output name=tag::${{ env.IS_PRERELEASE == 'true' && 'alpha' }}"
echo "::set-output name=tag_latest::${{ env.IS_PRERELEASE == 'true' && 'false' || 'true' }}"
release-container:
needs: release-container-prereq
uses: ./.github/workflows/reusable-container-workflow.yaml
with:
build_type: prod
tag: ${{ needs.release-container-prereq.outputs.tag }}
tag_latest: ${{ needs.release-container-prereq.outputs.tag_latest == 'true' }}
image: ghcr.io/${{ github.repository }}
registry: ghcr.io
registry_username: ${{ github.repository_owner }}
fetch_release: true
release_version: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
secrets:
registry_password: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2022-02-25 16:45:12 +00:00
release:
needs: [release-container-prereq, release-container]
2022-02-25 16:45:12 +00:00
runs-on: ubuntu-latest
steps:
- name: print_env
run: env
2022-02-25 16:45:12 +00:00
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install helm
uses: azure/setup-helm@v3
- name: Configure Git
if: env.IS_PRERELEASE != 'true'
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Update helm chart
if: env.IS_PRERELEASE != 'true'
run: |
git checkout main
sed -Ei \
-e 's/^(version\:) .*/\1 '${{ env.TAG_NAME }}'/g' \
-e 's/^(appVersion\:) .*/\1 "'${{ env.TAG_NAME }}'"/g' \
contrib/charts/dragonfly/Chart.yaml
git commit \
-m 'chore(helm-chart): update to ${{ env.TAG_NAME }}' \
contrib/charts/dragonfly/Chart.yaml
- name: Push Helm chart as OCI to Github
if: env.IS_PRERELEASE != 'true'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | \
helm registry login -u ${{ github.actor }} --password-stdin ghcr.io
helm package contrib/charts/dragonfly
helm push dragonfly-${{ env.TAG_NAME }}.tgz oci://ghcr.io/${{ github.repository }}/helm
- name: GitHub Push
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.DRAGONFLY_TOKEN }}
branch: main
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@0c4b27844ba47cb1c7bee539c8eead5284ce9fa9
with:
args: 'DragonflyDB version [${{ env.TAG_NAME }}](https://github.com/dragonflydb/dragonfly/releases/tag/${{ env.TAG_NAME }}) has been released 🎉'