|
| 1 | +name: 'Latest Passing Release' |
| 2 | +# run this once basic build passes tests on master branch |
| 3 | +# it will update the latest-passing-build tag, and update the github release |
| 4 | +on: |
| 5 | + workflow_run: |
| 6 | + workflows: ['Basic builds'] |
| 7 | + types: |
| 8 | + - completed |
| 9 | + branches: |
| 10 | + - master |
| 11 | + |
| 12 | +# https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_run |
| 13 | + |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 19 | + steps: |
| 20 | + - name: Info |
| 21 | + env: |
| 22 | + workflow: ${{ toJson(github.event.workflow_run) }} |
| 23 | + run: | |
| 24 | + echo "$workflow" | jq -r '"trying to release " + .head_branch + "(" + .head_commit.id + "): \"" + (.head_commit.message | split("\n")[0]) + "\" from " + .head_commit.author.name + " <" + .head_commit.author.email + ">, test builds started at " + .run_started_at + ", " + .html_url' |
| 25 | +
|
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@main |
| 28 | + - name: Configure |
| 29 | + run: | |
| 30 | + autoreconf -i . |
| 31 | + ./configure |
| 32 | + - name: make dist zip |
| 33 | + run: make dist-gzip VERSION=latest-$(git rev-parse --short HEAD) |
| 34 | + |
| 35 | + - name: recreate latest-passing-build tag |
| 36 | + env: |
| 37 | + RUN_URL: ${{ github.event.workflow_run.html_url }} |
| 38 | + run: | |
| 39 | + git config user.name "GitHub Actions" |
| 40 | + git config user.email "github-actions@users.noreply.github.com" |
| 41 | + git tag -f latest-passing-build -F- <<EOF |
| 42 | + Latest Passing Build |
| 43 | +
|
| 44 | + This is the automatic release from Github Actions. |
| 45 | +
|
| 46 | + Whenever a build passes, it gets released as Latest Passing Build. |
| 47 | +
|
| 48 | + Date: $(date --iso=s) |
| 49 | + SHA: $(git rev-parse --short HEAD) |
| 50 | + Log: $RUN_URL |
| 51 | + EOF |
| 52 | +
|
| 53 | + git push origin --force latest-passing-build |
| 54 | +
|
| 55 | + - name: Update release |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + run: | |
| 59 | + gh release view latest-passing-build --json assets --jq '.assets[] | .name' | xargs --no-run-if-empty -n1 gh release delete-asset latest-passing-build |
| 60 | + gh release edit latest-passing-build -n "$(git tag -l --format='%(body)' latest-passing-build)" -t "$(git tag -l --format='%(subject)' latest-passing-build)" |
| 61 | + gh release upload latest-passing-build cpputest-latest-$(git rev-parse --short HEAD).tar.gz |
0 commit comments