-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Weekly proxy release | ||
|
||
on: | ||
schedule: | ||
# Wednesday at ~10PM Pacific | ||
- cron: "0 5 * * 4" | ||
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 |