Skip to content

Commit

Permalink
Add gh action to vendor Cargo source
Browse files Browse the repository at this point in the history
  • Loading branch information
declantsien committed Apr 15, 2024
1 parent 03bd58e commit 9a941f7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 18 deletions.
17 changes: 12 additions & 5 deletions .envrc
Original file line number Diff line number Diff line change
@@ -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
39 changes: 26 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ jobs:

build:
needs: prepare_env
name: Build 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
Expand All @@ -71,23 +70,37 @@ 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=Vendored\ source\ code_$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
if: ${{ matrix.build != 'vendor' }}
continue-on-error: true
run: |
## Reduce Cache
Expand Down Expand Up @@ -115,15 +128,15 @@ 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'
id: upload_release_asset
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 }}
File renamed without changes.
20 changes: 20 additions & 0 deletions admin/vendor_cargo_source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [[ -z $@ ]]; then
echo "Usage: ./vendor_cargo_source.sh <emacs_version>"
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

0 comments on commit 9a941f7

Please sign in to comment.