nightly-release.yaml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #
  5. # This workflow creates a GitHub "release" of a nightly build of the project.
  6. #
  7. # Note: This is just an initial rough attempt, there is a lot of future work
  8. # needed here. A brief summary of TODOs:
  9. #
  10. # - Configure a nice release notes template and switch to generating the title
  11. # and notes instead of hard coding them.
  12. #
  13. # - Do some amount of testing prior to building and uploading the release.
  14. # - Tempting to try to examine existing testing workflow, but maybe better to
  15. # allow re-using any complex parts and do our own testing. That would, for
  16. # example, allow us to narrow or expand the set of tests uses for
  17. # pre-release testing to potentially be different from continuous testing.
  18. # - Some questions around what to do in the event of a failure... error? Where
  19. # does the error go? Create a draft, unpublished release instead?
  20. #
  21. # - Build artifacts for all the different OSes we have GitHub runners for rather
  22. # than just x86 Linux.
  23. name: Nightly Release
  24. on:
  25. schedule:
  26. - cron: '0 2 * * *'
  27. # Enable manual runs for testing or manually (re-)creating a nightly release.
  28. workflow_dispatch:
  29. permissions:
  30. contents: write # For creating and uploading to releases.
  31. jobs:
  32. release:
  33. runs-on: ubuntu-22.04
  34. steps:
  35. - name: Harden Runner
  36. uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
  37. with:
  38. egress-policy: audit
  39. - name: Checkout branch
  40. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  41. - name: Set up remote cache access
  42. env:
  43. REMOTE_CACHE_KEY: ${{ secrets.CARBON_BUILDS_GITHUB }}
  44. run: |
  45. echo "$REMOTE_CACHE_KEY" | base64 -d > $HOME/remote_cache_key.json
  46. echo "remote_cache_upload=--google_credentials=$HOME/remote_cache_key.json" \
  47. >> $GITHUB_ENV
  48. - uses: ./.github/actions/build-setup-common
  49. with:
  50. matrix_runner: ubuntu-22.04
  51. remote_cache_upload: ${{ env.remote_cache_upload }}
  52. - name: Get nightly date
  53. run: |
  54. echo "nightly_date=$(date '+%Y.%m.%d')" >> $GITHUB_ENV
  55. - name: Build release
  56. run: |
  57. ./scripts/run_bazel.py \
  58. --attempts=5 --jobs-on-last-attempt=4 \
  59. test -c opt --remote_download_toplevel \
  60. --pre_release=nightly --nightly_date=${{ env.nightly_date }} \
  61. //toolchain/install:prefix_root/bin/carbon \
  62. //toolchain/install:carbon_toolchain_tar_gz_rule \
  63. //toolchain/install:carbon_toolchain_tar_gz_test
  64. - name: Extract the release version
  65. run: |
  66. # Make sure we can run the toolchain to get the version.
  67. ./bazel-bin/toolchain/install/prefix_root/bin/carbon version
  68. # Now stash it in a variable and export it.
  69. VERSION=$( \
  70. ./bazel-bin/toolchain/install/prefix_root/bin/carbon version \
  71. | cut -d' ' -f5 | cut -d'+' -f1)
  72. echo "release_version=$VERSION" >> $GITHUB_ENV
  73. - name: Create the release
  74. env:
  75. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  76. run: |
  77. gh release create \
  78. --title "Nightly build ${{ env.nightly_date }}" \
  79. --notes 'A nightly development build of Carbon.' \
  80. --prerelease \
  81. v${{ env.release_version }} \
  82. "bazel-bin/toolchain/install/carbon_toolchain-${{ env.release_version }}.tar.gz"