Skip to content

Commit

Permalink
ci: Automate weekly proxy releases
Browse files Browse the repository at this point in the history
This commit adds a release-weekly workflow that runs on Wednesday nights. If
there hasn't been a proxy release earlier in the week and there are new commits
on main, then a new release is triggered.
  • Loading branch information
olix0r committed Mar 25, 2024
1 parent c07e97b commit a922287
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/release-weekly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Weekly proxy release

on:
schedule:
# Wednesday at ~8:10PM Pacific
- cron: "10 3 * * 3"
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
last-release:
if: github.repository == 'linkerd/linkerd2-proxy' # Don't run this in forks.
runs-on: ubuntu-22.04
timeout-minutes: 5
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
steps:
- name: Latest release
id: latest
run: gh release view --json name,publishedAt | jq -r 'to_entries[] | (.key + "=" + .value)' >> "$GITHUB_OUTPUT"
- name: Check if release was in last 72 hours
id: recency
env:
PUBLISHED_AT: ${{ steps.latest.outputs.publishedAt }}
run: |
if [ "$(date -d "$PUBLISHED_AT" +%s)" -gt "$(date -d '72 hours ago' +%s)" ]; then
echo "Last release $PUBLISHED_AT is recent" >&2
echo "recent=true" >> "$GITHUB_OUTPUT"
else
echo "Last release $PUBLISHED_AT is not recent" >&2
echo "recent=false" >> "$GITHUB_OUTPUT"
fi
outputs:
version: ${{ steps.latest.outputs.name }}
published-at: ${{ steps.latest.outputs.publishedAt }}
recent: ${{ steps.recency.outputs.recent == 'true' }}

last-commit:
needs: last-release
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- name: Check if the most recent commit is after the last release
id: recency
env:
PUBLISHED_AT: ${{ needs.last-release.outputs.published-at }}
run: |
if [ "$(git log -1 --format=%ct)" -gt "$(date -d "$PUBLISHED_AT" +%s)" ]; then
echo "HEAD after last release $PUBLISHED_AT" >&2
echo "after-release=true" >> "$GITHUB_OUTPUT"
else
echo "after-release=false" >> "$GITHUB_OUTPUT"
fi
outputs:
after-release: ${{ steps.recency.outputs.after-release == 'true' }}

trigger-release:
needs: [last-release, last-commit]
if: needs.last-release.outputs.recent == 'false' && needs.last-commit.outputs.after-release == 'true'
runs-on: ubuntu-22.04
timeout-minutes: 5
permissions:
actions: write
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
LAST_VERSION: ${{ needs.last-release.outputs.version }}
steps:
- name: Get the latest minor version
run: |
m="$(echo "$LAST_VERSION" | cut -d. -f2)"
echo MINOR_VERSION="$((m+1))" >> "$GITHUB_ENV"
- run: gh workflow run release.yml -f publish=true -f version=v2."$MINOR_VERSION".0

0 comments on commit a922287

Please sign in to comment.