nightly_release.yaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
  37. with:
  38. egress-policy: block
  39. # When adding endpoints, see README.md.
  40. # prettier-ignore
  41. allowed-endpoints: >
  42. *.dl.sourceforge.net:443
  43. api.github.com:443
  44. bcr.bazel.build:443
  45. downloads.sourceforge.net:443
  46. github.com:443
  47. oauth2.googleapis.com:443
  48. objects.githubusercontent.com:443
  49. releases.bazel.build:443
  50. sourceforge.net:443
  51. storage.googleapis.com:443
  52. uploads.github.com:443
  53. - name: Checkout branch
  54. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  55. - name: Set up remote cache access
  56. env:
  57. REMOTE_CACHE_KEY: ${{ secrets.CARBON_BUILDS_GITHUB }}
  58. run: |
  59. echo "$REMOTE_CACHE_KEY" | base64 -d > $HOME/remote_cache_key.json
  60. echo "remote_cache_upload=--google_credentials=$HOME/remote_cache_key.json" \
  61. >> $GITHUB_ENV
  62. - uses: ./.github/actions/build-setup-common
  63. with:
  64. matrix_runner: ubuntu-22.04
  65. remote_cache_upload: ${{ env.remote_cache_upload }}
  66. - name: Get nightly date
  67. run: |
  68. echo "nightly_date=$(date '+%Y.%m.%d')" >> $GITHUB_ENV
  69. - name: Build release
  70. run: |
  71. ./scripts/run_bazel.py \
  72. --attempts=5 --jobs-on-last-attempt=4 \
  73. test -c opt --remote_download_toplevel \
  74. --pre_release=nightly --nightly_date=${{ env.nightly_date }} \
  75. //toolchain \
  76. //toolchain/install:carbon_toolchain_tar_gz_rule \
  77. //toolchain/install:carbon_toolchain_tar_gz_test
  78. - name: Extract the release version
  79. run: |
  80. # Make sure we can run the toolchain to get the version.
  81. ./bazel-bin/toolchain/carbon version
  82. # Now stash it in a variable and export it.
  83. VERSION=$( \
  84. ./bazel-bin/toolchain/carbon version \
  85. | cut -d' ' -f5 | cut -d'+' -f1)
  86. echo "release_version=$VERSION" >> $GITHUB_ENV
  87. - name: Create the release
  88. env:
  89. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  90. run: |
  91. gh release create \
  92. --title "Nightly build ${{ env.nightly_date }}" \
  93. --generate-notes \
  94. --prerelease \
  95. v${{ env.release_version }} \
  96. "bazel-bin/toolchain/install/carbon_toolchain-${{ env.release_version }}.tar.gz"