From db1f1ed6e3d10939e669e718a5c5a4cfd0a2a2c7 Mon Sep 17 00:00:00 2001 From: Declan Tsien Date: Mon, 15 Apr 2024 12:24:13 +0800 Subject: [PATCH] Add gh action to vendor Cargo source --- .envrc | 17 ++++++--- .github/workflows/release.yml | 39 +++++++++++++------- build_emacs_ng.sh => admin/build_emacs_ng.sh | 0 admin/vendor_cargo_source.sh | 20 ++++++++++ 4 files changed, 58 insertions(+), 18 deletions(-) rename build_emacs_ng.sh => admin/build_emacs_ng.sh (100%) create mode 100755 admin/vendor_cargo_source.sh diff --git a/.envrc b/.envrc index 1a8c3a7408e..71c3f07646e 100644 --- a/.envrc +++ b/.envrc @@ -1,5 +1,12 @@ -watch_file nix/* flake.nix -{ - mkdir -p "$(direnv_layout_dir)" - eval "$(nix print-dev-env --no-update-lock-file --no-write-lock-file --profile $(direnv_layout_dir)/flake-profile)" -} || use nix +export GUILE_LOAD_PATH="$HOME/src/guix-channel/:$GUILE_LOAD_PATH" +use guix + +export RUST_SRC_PATH="$HOME/src/rust/library" + +export LD_LIBRARY_PATH=$LIBRARY_PATH +rm /tmp/cc +ln -s $(guix build clang)/bin/clang /tmp/cc +export PATH=$PATH:/tmp +export LIBCLANG_PATH=$(guix build clang)/lib +unset EMACSLOADPATH +unset EMACSNATIVELOADPATH diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d91beefbc24..ca3d53dcb04 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,12 +45,12 @@ jobs: build: needs: prepare_env - name: Build and release + name: Build/Vendor and release runs-on: ubuntu-latest strategy: fail-fast: false matrix: - build: [general, webrender] + build: [general, webrender, vendor] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CARGO_INCREMENTAL: 0 @@ -71,22 +71,35 @@ jobs: key: ${{ runner.os }}-${{ matrix.build }}-cargo-${{ needs.prepare_env.outputs.rust_cache }} restore-keys: | ${{ runner.os }}-${{ matrix.build }}-cargo + - name: Cargo Vendor + if: ${{ matrix.build == 'vendor' }} + run: | + version=${{ needs.prepare_env.outputs.version }} + artifacts=emacs-ng_$version\.tar.xz + artifactContentType= + echo "version=$version" >> $GITHUB_ENV + echo "artifacts=$artifacts" >> $GITHUB_ENV + echo "content_type=application/x-xz-compressed-tar" >> $GITHUB_ENV + ./admin/vendor_cargo_source.sh $version - name: Build project if: ${{ matrix.build == 'general' }} run: | version=${{ needs.prepare_env.outputs.version }} - bin_version=$version + artifacts=emacs-ng_$version\_${{ needs.prepare_env.outputs.arch }}.deb echo "version=$version" >> $GITHUB_ENV - echo "bin_version=$bin_version" >> $GITHUB_ENV - ./build_emacs_ng.sh $bin_version + echo "artifacts=$artifacts" >> $GITHUB_ENV + echo "content_type=application/vnd.debian.binary-package" >> $GITHUB_ENV + ./admin/build_emacs_ng.sh $version - name: Build project with webrender if: ${{ matrix.build == 'webrender' }} run: | version=${{ needs.prepare_env.outputs.version }} - bin_version=$version.webrender + bin_version=$version\.webrender + artifacts=emacs-ng_$bin_version\_${{ needs.prepare_env.outputs.arch }}.deb echo "version=$version" >> $GITHUB_ENV - echo "bin_version=$bin_version" >> $GITHUB_ENV - ./build_emacs_ng.sh $bin_version --with-webrender --with-winit + echo "artifacts=$artifacts" >> $GITHUB_ENV + echo "content_type=application/vnd.debian.binary-package" >> $GITHUB_ENV + ./admin/build_emacs_ng.sh $bin_version --with-webrender --with-winit - name: Reduce cache continue-on-error: true run: | @@ -115,8 +128,8 @@ jobs: draft: false prerelease: ${{ needs.prepare_env.outputs.prerelease }} artifactErrorsFailBuild: true - artifacts: ./emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb - artifactContentType: application/vnd.debian.binary-package + artifacts: ./${{ env.artifacts }} + artifactContentType: ${{ env.content_type }} token: ${{ secrets.GITHUB_TOKEN }} - name: Do upload to release if: steps.get_release_by_tag.outcome == 'success' @@ -124,6 +137,6 @@ jobs: uses: actions/upload-release-asset@v1 with: upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }} - asset_path: ./emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb - asset_name: emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb - asset_content_type: application/vnd.debian.binary-package + asset_path: ./${{ env.artifacts }} + asset_name: ${{ env.artifacts }} + asset_content_type: ${{ env.content_type }} diff --git a/build_emacs_ng.sh b/admin/build_emacs_ng.sh similarity index 100% rename from build_emacs_ng.sh rename to admin/build_emacs_ng.sh diff --git a/admin/vendor_cargo_source.sh b/admin/vendor_cargo_source.sh new file mode 100755 index 00000000000..c3485d18fee --- /dev/null +++ b/admin/vendor_cargo_source.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [[ -z $@ ]]; then + echo "Usage: ./vendor_cargo_source.sh " +fi + +mkdir -p .cargo +cargo vendor ./third_party/rust --respect-source-config > \ + .cargo/config.toml + +git config --global user.email "bot@github.io" +git config --global user.name "github bot" +git config tar.tar.xz.command "xz -c" +git add -f ./third_party/rust +git add .cargo/config.toml +git commit --no-verify -m "Vendor Cargo Source" + +prefix=emacs-ng_$1 + +git archive --prefix=$prefix/ HEAD -o $prefix.tar.xz