The (very WIP) home of the next versions of my web presences

build: support Render previews given its limitations

I am changing my assumptions, after much thinking about how to wrangle
this at some length.

1. I will not try to do preview changes for `lx` on Render.
2. I can therefore have Render always use the *latest* build of `lx`,
rather than mucking around with specific versions.
3. I will thus only deploy new builds of `lx` from `main`.
4. I still need to avoid “auto-deploying”, so that I only deploy once a
release has been created, for the cases where I have made changes to
`lx` that might break existing templates.

Net, then, I need to only trigger a deploy on `main` (while keeping the
existing rules in place, too), and on the build script side just always
use the latest version, not mucking around with PR versions.

Changed files
+21 -61
.github
workflows
_scripts
+15 -28
.github/workflows/CI and CD.yml
··· 60 60 release: 61 61 name: Create and upload release 62 62 needs: [check] 63 - if: ${{ 64 - github.event.push.commits.author.username == 'chriskrycho' || 65 - github.event.pull_request.user.login == 'chriskrycho' || 66 - github.actor == 'chriskrycho' 67 - }} 63 + if: ${{ github.event.push.commits.author.username == 'chriskrycho' && github.ref == 'refs/heads/main'}} 68 64 permissions: 69 65 contents: write 70 66 runs-on: ubuntu-22.04 ··· 74 70 - name: Create release build 75 71 run: cargo build --locked --release 76 72 77 - - name: Confirm release results 78 - run: | 79 - ls -l target/release/lx 80 - mv target/release/lx lx-linux 73 + - name: Show release build info 74 + run: ls -l target/release/lx 75 + 76 + - name: Rename and move release binary 77 + run: mv target/release/lx lx-linux 81 78 82 79 - name: Generate Release Name 83 80 id: release_name ··· 91 88 fail_on_unmatched_files: true 92 89 name: ${{ steps.release_name.outputs.release_name }} 93 90 tag_name: ${{ steps.release_name.outputs.release_name }} 94 - prerelease: ${{ github.event_name == 'pull_request' }} 95 91 env: 96 92 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 97 93 ··· 125 121 trigger-deploy-music: 126 122 needs: [changes, build-check] 127 123 if: ${{ 128 - ((needs.changes.outputs.music == 'true' || needs.changes.outputs.cfg == 'true' || github.event_name == 'workflow_dispatch') 129 - && needs.build-check.outputs.state == 'non-needed' 130 - ) 131 - || needs.build-check.outputs.state == 'succeeded' 124 + github.ref == 'refs/heads/main' && 125 + (((needs.changes.outputs.music == 'true' || needs.changes.outputs.cfg == 'true' || github.event_name == 'workflow_dispatch') 126 + && needs.build-check.outputs.state == 'non-needed') 127 + || needs.build-check.outputs.state == 'succeeded') 132 128 }} 133 129 runs-on: ubuntu-22.04 134 130 steps: ··· 136 132 - name: Render deploy hook 137 133 env: 138 134 deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_MUSIC }} 139 - run: | 140 - if [[ "${{ github.event_name }}" == "pull_request" ]]; then 141 - SHA=$(git rev-parse --short HEAD) 142 - deploy_url="${deploy_url}&ref=${SHA}" 143 - fi 144 - curl "$deploy_url" 135 + run: curl "$deploy_url" 145 136 146 137 trigger-deploy-v6: 147 138 needs: [changes, build-check] 148 139 if: ${{ 149 - ((needs.changes.outputs.v6 == 'true' || needs.changes.outputs.cfg == 'true' || github.event_name == 'workflow_dispatch') 140 + github.ref == 'refs/heads/main' && 141 + (((needs.changes.outputs.v6 == 'true' || needs.changes.outputs.cfg == 'true' || github.event_name == 'workflow_dispatch') 150 142 && needs.build-check.outputs.state == 'non-needed') 151 - || needs.build-check.outputs.state == 'succeeded' 143 + || needs.build-check.outputs.state == 'succeeded') 152 144 }} 153 145 runs-on: ubuntu-22.04 154 146 steps: ··· 156 148 - name: Render deploy hook 157 149 env: 158 150 deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_V6 }} 159 - run: | 160 - if [[ "${{ github.event_name }}" == "pull_request" ]]; then 161 - SHA=$(git rev-parse --short HEAD) 162 - deploy_url="${deploy_url}&ref=${SHA}" 163 - fi 164 - curl "$deploy_url" 151 + run: curl "$deploy_url"
+5 -33
_scripts/build.sh
··· 22 22 OUTPUT="lx-cli" 23 23 rm -f $OUTPUT 24 24 25 - download() { 26 - local url="$1" 27 - local output="$2" 28 - 29 - echo "fetching '$url' to '$output'" 30 - 31 - curl --location \ 25 + echo "fetching '$LATEST' to '$OUTPUT'" 26 + curl --location \ 32 27 --proto '=https' --tlsv1.2 \ 33 28 --silent --show-error --fail \ 34 - --output "$output" \ 35 - "$url" 36 - } 37 - 38 - # Note for jj usage (read: local testing): make sure the repo is colocated! 39 - download_for_pr() { 40 - local sha 41 - sha=$(git rev-parse --short HEAD) 42 - 43 - local pr="${RELEASES}/download/lx-${sha}/lx-linux" 44 - 45 - local pr_result 46 - pr_result=$(download "$pr" "$OUTPUT") 47 - 48 - local pr_exit=$?; 49 - echo "PR: $pr_exit $pr_result" 50 - 51 - if [[ "$pr_exit" -ne 0 ]]; then 52 - echo "falling back to latest: $LATEST" 53 - download $LATEST $OUTPUT 54 - fi 55 - } 56 - 57 - # This works regardless of whether Render understands that a given deploy hook 58 - # was triggered by a pull request or not. 59 - download_for_pr || exit $? 29 + --output "$OUTPUT" \ 30 + "$LATEST" \ 31 + || exit $? 60 32 61 33 chmod +x $OUTPUT 62 34
+1
render.yaml
··· 23 23 paths: 24 24 - site/styles/** 25 25 - sites/music/** 26 + - sites/_shared/** 26 27 buildCommand: | 27 28 bash ./_scripts/build.sh music 28 29