nightly_release.yaml 4.3 KB

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