|
3 | 3 | pull_request:
|
4 | 4 | branches:
|
5 | 5 | - main
|
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
6 | 9 |
|
7 | 10 | jobs:
|
8 | 11 | build:
|
|
15 | 18 | - name: build
|
16 | 19 | run: nix-build -A ci
|
17 | 20 |
|
| 21 | + # Creates a release commit and combines the changelog files into a single one |
| 22 | + # For PRs it shows the resulting changelog in the step summary |
| 23 | + # For pushes to the main branch it updates the release branch |
| 24 | + # The release branch is regularly |
| 25 | + version-changelog: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + # This job only needs this token to read commit objects to figure out what PR they're associated with. |
| 29 | + # A separate fixed token is used to update the release branch after push events. |
| 30 | + contents: read |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + # This fetches the entire Git history. |
| 35 | + # This is needed so we can determine the commits (and therefore PRs) |
| 36 | + # where the changelogs have been added |
| 37 | + fetch-depth: 0 |
| 38 | + # By default, the github.token is used and stored in the Git config, |
| 39 | + # This would override any authentication provided in the URL, |
| 40 | + # which we do later to push to a fork. |
| 41 | + # So we need to prevent that from being stored. |
| 42 | + persist-credentials: false |
| 43 | + |
| 44 | + - uses: cachix/install-nix-action@v26 |
| 45 | + |
| 46 | + - name: Increment version and assemble changelog |
| 47 | + run: | |
| 48 | + nix-build -A autoVersion |
| 49 | + # If we're running for a PR, the second argument tells the script to pretend that commits |
| 50 | + # from this PR are merged already, such that the generated changelog includes it |
| 51 | + version=$(result/bin/auto-version . ${{ github.event.pull_request.number || '' }}) |
| 52 | + echo "version=$version" >> "$GITHUB_ENV" |
| 53 | +
|
| 54 | + # version is the empty string if there were no user-facing changes for a version bump |
| 55 | + if [[ -n "$version" ]]; then |
| 56 | + # While we commit here, it's only pushed conditionally based on it being a push event later |
| 57 | + git config user.name ${{ github.actor }} |
| 58 | + git config user.email ${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com |
| 59 | + git add --all |
| 60 | + git commit --message "Version $version |
| 61 | +
|
| 62 | + Automated release" |
| 63 | + fi |
| 64 | + env: |
| 65 | + GH_TOKEN: ${{ github.token }} |
| 66 | + |
| 67 | + - name: Outputting draft release notes |
| 68 | + # If we have a new version at all (it's not an empty string) |
| 69 | + # And it's not a push event (so it's a PR), |
| 70 | + if: ${{ env.version && github.event_name != 'push' }} |
| 71 | + # we just output the draft changelog into the step summary |
| 72 | + run: cat changes/released/${{ env.version }}.md > "$GITHUB_STEP_SUMMARY" |
| 73 | + |
| 74 | + - name: Update release branch |
| 75 | + # But if this is a push to the main branch, |
| 76 | + if: ${{ env.version && github.event_name == 'push' }} |
| 77 | + # we push to the release branch. |
| 78 | + # This continuously updates the release branch to contain the latest release notes, |
| 79 | + # so that one can just merge the release branch into main to do a release. |
| 80 | + # A PR to do that is opened regularly with another workflow |
| 81 | + run: git push https://${{ secrets.MACHINE_USER_PAT }}@github.com/infinixbot/nixpkgs-check-by-name.git HEAD:refs/heads/release -f |
| 82 | + |
| 83 | + |
18 | 84 | test-update:
|
19 | 85 | runs-on: ubuntu-latest
|
20 | 86 | steps:
|
|
0 commit comments