diff --git a/.github/workflows/shared.yml b/.github/workflows/shared.yml index 404ec955c8..28f879b157 100644 --- a/.github/workflows/shared.yml +++ b/.github/workflows/shared.yml @@ -91,7 +91,7 @@ jobs: - name: Build binary run: | - echo "${{ inputs.pace }}" > ./pkg/vere/PACE + echo "${{ inputs.pace }}" > ./PACE case "${{ matrix.target }}" in "linux-aarch64") bazel build --platforms=//:linux-aarch64 :urbit @@ -146,7 +146,7 @@ jobs: - name: Upload binary to bootstrap.urbit.org if: ${{ inputs.upload }} run: | - version="$(cat ./pkg/vere/VERSION)" + version="$(cat ./VERSION)" target="gs://${UPLOAD_BASE}/${{ inputs.pace }}/v${version}/vere-v${version}-${{ matrix.target }}" # See https://github.com/urbit/vere/issues/86. @@ -228,7 +228,7 @@ jobs: - name: Build and push Docker image if: ${{ inputs.docker && matrix.target == 'linux-x86_64' }} run: | - version="v$(cat ./pkg/vere/VERSION)" + version="v$(cat ./VERSION)" tag="$version-${{ inputs.pace }}" bazel run :upload_docker @@ -253,13 +253,13 @@ jobs: target="gs://${UPLOAD_BASE}/${{ inputs.pace }}/last" # See https://github.com/urbit/vere/issues/86. - if [[ $(cat ./pkg/vere/VERSION) == "1.16" ]]; then - gsutil cp ./pkg/vere/VERSION "gs://${UPLOAD_BASE}/${{ inputs.pace }}/1.15/next" + if [[ $(cat ./VERSION) == "1.16" ]]; then + gsutil cp ./VERSION "gs://${UPLOAD_BASE}/${{ inputs.pace }}/1.15/next" fi # We don't use -n here because we want to overwrite the version # string. - gsutil cp ./pkg/vere/VERSION "$target" + gsutil cp ./VERSION "$target" [ $exitcode -eq 0 ] && echo "Upload to $target completed successfully." || diff --git a/BUILD.bazel b/BUILD.bazel index 2e222352f4..10515c44cc 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -126,6 +126,47 @@ platform( ], ) +# Produce the `U3_VERE_PACE` macro. +genrule( + name = "pace", + srcs = ["PACE"], + outs = ["pace.h"], + cmd = """ + echo '#ifndef URBIT_PACE_H' > $@ + echo '#define URBIT_PACE_H' >> $@ + printf '#define U3_VERE_PACE "%s"\n' $$(cat $< | tr -d '\n') >> $@ + echo '#endif' >> $@ + """, + visibility = ["//:__subpackages__"], +) + +# Produce the `URBIT_VERSION` macro. +genrule( + name = "version", + srcs = [ + # Bazel warns dependency checking directories is unsound, but there's no + # apparent way around depending on .git if we want to run git commands. + ".git", + "PACE", + "VERSION", + ], + outs = ["version.h"], + cmd = """ + version_num=`cat $(execpath VERSION) | tr -d '\n'` + commit_sha=`git rev-parse --short HEAD` + if [ `tr -d '\n' < $(execpath PACE)` == "live" ]; then + version="$$version_num" + else + version="$$version_num-$$commit_sha" + fi + echo '#ifndef URBIT_VERSION_H' > $@ + echo '#define URBIT_VERSION_H' >> $@ + printf '#define URBIT_VERSION "%s"\n' $$version >> $@ + echo '#endif' >> $@ + """, + visibility = ["//:__subpackages__"], +) + alias( name = "urbit", actual = "//pkg/vere:urbit", diff --git a/PACE b/PACE new file mode 100644 index 0000000000..b2d1a7762f --- /dev/null +++ b/PACE @@ -0,0 +1 @@ +once diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..68209c0009 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.17 \ No newline at end of file diff --git a/pkg/vere/BUILD.bazel b/pkg/vere/BUILD.bazel index 4a24a28113..17656c5946 100644 --- a/pkg/vere/BUILD.bazel +++ b/pkg/vere/BUILD.bazel @@ -2,8 +2,6 @@ # GENERATED FILES # -exports_files(["PACE", "VERSION"]) - # An approximation of `xxd -i` that runs on all platforms where Bash is # present. Generates a `.h` file that declares the array and array length as # `extern` global variables and a `.c` file containing the array and array @@ -84,34 +82,6 @@ genrule( visibility = ["//visibility:private"], ) -# Produce the `URBIT_VERSION` macro. -genrule( - name = "version", - srcs = ["VERSION"], - outs = ["version.h"], - cmd = """ - echo '#ifndef URBIT_VERSION_H' > $@ - echo '#define URBIT_VERSION_H' >> $@ - printf '#define URBIT_VERSION "%s"\n' $$(cat $<) >> $@ - echo '#endif' >> $@ - """, - visibility = ["//visibility:private"], -) - -# Produce the `U3_VERE_PACE` macro. -genrule( - name = "pace", - srcs = ["PACE"], - outs = ["pace.h"], - cmd = """ - echo '#ifndef URBIT_PACE_H' > $@ - echo '#define URBIT_PACE_H' >> $@ - printf '#define U3_VERE_PACE "%s"\n' $$(cat $<) >> $@ - echo '#endif' >> $@ - """, - visibility = ["//visibility:private"], -) - # # LIBRARIES # @@ -132,8 +102,8 @@ cc_library( ], ) + [ ":ivory", - ":pace", - ":version", + "//:pace", + "//:version", ] + select({ "@platforms//os:macos": [ "platform/darwin/daemon.c", @@ -174,8 +144,8 @@ cc_binary( "main.c", ":ca_bundle", ":ivory", - ":pace", - ":version", + "//:pace", + "//:version", ], features = select({ "@platforms//os:linux": ["fully_static_link"],