nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.62k stars 623 forks source link

Add CI job to build and upload artifact bundle for releases #1721

Closed calda closed 3 weeks ago

calda commented 3 weeks ago

This PR adds a GitHub Actions CI job that builds swiftformat.artifactbundle.zip for each new release and automatically uploads / attached it to the release page.

I cut new releases regularly over in https://github.com/calda/SwiftFormat/releases, so automating this process would be helpful. To use this job in that repo I have to upstream it here. I don't know how you're managing this today, but hopefully automating this is helpful for you as well!

I verified that the artifact bundle can be consumed properly by Swift Package Manager.

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.23%. Comparing base (b0d492f) to head (ae906cb).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1721 +/- ## =========================================== + Coverage 95.19% 95.23% +0.04% =========================================== Files 20 20 Lines 23248 23248 =========================================== + Hits 22131 22141 +10 + Misses 1117 1107 -10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

nicklockwood commented 3 weeks ago

This is super-helpful, thank you! Creating the artifact bundle is certainly one of the more annoying manual steps in the release process.

nicklockwood commented 2 weeks ago

I'm not sure I understand how this is triggered? I was expecting it to run automatically when the release was created, but that didn't happen. Do I need to create build jobs with particular names as you have done?

calda commented 2 weeks ago

When I was testing in my fork, this ran automatically after tagging a new release.

I see here that no runs of the job have been triggered: https://github.com/nicklockwood/SwiftFormat/actions/workflows/release.yml

So, I don’t know what the problem could be… maybe try again now that the commit with that job is merged to the default branch (master in your repo)? Not sure if that could be relevant or not

I'll see if I can figure out what the issue could be

nicklockwood commented 2 weeks ago

I merged it prior to tagging the release, so I don't think that's it. It might be easier just to give it a manual trigger anyway, as the release process is sometimes a bit chaotic anyway if something fails and I have to rebase and re-tag.

calda commented 2 weeks ago

Looking at the documentation here. Right now the job uses a release: [created] trigger:

Note: Workflows are not triggered for the created, edited, or deleted activity types for draft releases. When you create your release through the GitHub browser UI, your release may automatically be saved as a draft.

This is probably the most likely explanation.

It sounds like the recommended trigger is published rather than created:

on:
  release:
    types: [published]
calda commented 2 weeks ago

Maybe https://github.com/nicklockwood/SwiftFormat/pull/1730 will fix it

calda commented 2 weeks ago

Here's another permission you could check: https://github.com/skx/github-action-publish-binaries#github_token

That permission being incorrect would probably make the job fail, rather than just not start in the first place. So, unlikely to be related to this specific issue. But still important to have it configured as needed.