Skip to content

Commit

Permalink
Merge pull request #299 from alerque/bootstrapable
Browse files Browse the repository at this point in the history
Build standalone script edition in CI
  • Loading branch information
RichiH authored Jun 17, 2021
2 parents 076a000 + 5bcb2ea commit 4f013c3
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 23 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build

on: [push, pull_request]

jobs:

standalone:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch tags
run: |
git fetch --prune --tags ||:
- name: Configure standalone script
run: |
./bootstrap.sh
./configure --with-standalone --bindir=/
make DESTDIR=. install-exec
echo VERSION=$(cat .version) >> $GITHUB_ENV
- name: Post standalone script artifact
uses: actions/upload-artifact@v2
with:
name: standalone-deployment-${{ env.VERSION }}
path: vcsh-standalone.sh

source-dist:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch tags
run: |
git fetch --prune --tags ||:
- name: Install build dependencies
run: |
sudo apt install -y ronn
- name: Install perl test dependencies
uses: perl-actions/[email protected]
with:
install: |
Shell::Command
Test::Most
- name: Configure
run: |
./bootstrap.sh
./configure
- name: Run tests
run: |
make check
- name: Build source package
run: |
make dist
echo VERSION=$(cat .version) >> $GITHUB_ENV
- name: Post build artifacts
uses: actions/upload-artifact@v2
with:
name: vcsh-${{ env.VERSION }}
path: vcsh-${{ env.VERSION }}.zip
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: Lint

on: [push, pull_request]

jobs:

editor-config:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Lint code style
uses: editorconfig-checker/[email protected]

shellcheck:
runs-on: ubuntu-latest
steps:
Expand Down
33 changes: 24 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,27 @@ on:

jobs:

ghrelase:
ghrelease:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install ronn
- name: Install build dependencies
run: |
sudo apt update
sudo apt install -y ronn
- name: Configure
run: |
echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
echo "${GITHUB_REF#refs/*/v}" > .tarball-version
./bootstrap.sh
./configure
- name: Build source package
run: |
make dist
- name: Check source package behaviour
run: |
make distcheck
- name: Make sure changelog was updated
run: |
make changelog-HEAD
grep -F "* Release ${{ env.VERSION }}" changelog-HEAD
- name: Build source package
run: |
make dist
- name: Publish Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -41,3 +37,22 @@ jobs:
vcsh-${{ env.VERSION }}.tar.xz
env:
GITHUB_TOKEN: ${{ github.token }}

deploy-standalone:
runs-on: ubuntu-latest
needs: [ ghrelease ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure standalone script
run: |
echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
./bootstrap.sh
./configure --with-standalone --bindir=/
make DESTDIR=. install-exec
- name: Add standalone deployment to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ github.token }}
file: vcsh-standalone.sh
tag: ${{ github.ref }}
17 changes: 7 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Test

on: [push, pull_request]

jobs:

test:
runs-on: ubuntu-latest
steps:
Expand All @@ -11,9 +14,9 @@ jobs:
- name: Fetch tags
run: |
git fetch --prune --tags ||:
- name: Install dependencies
- name: Install build dependencies
run: |
sudo apt install ronn
sudo apt install -y ronn
- name: Install perl test dependencies
uses: perl-actions/[email protected]
with:
Expand All @@ -27,12 +30,6 @@ jobs:
- name: Run tests
run: |
make check
- name: Build source package
- name: Run full cycle packaging check
run: |
make dist
echo VERSION=$(cat .version) >> $GITHUB_ENV
- name: Post build artifacts
uses: actions/upload-artifact@v2
with:
name: vcsh-${{ env.VERSION }}
path: vcsh-${{ env.VERSION }}.zip
make distcheck
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ unreleased
* Allow use of specific path when running Git or any dependency
* Fail if hook scripts return failure codes
* Check GIT_REMOTE early on clone()
* Support renaming script as configuration option
* Setup standalone script build profile and attach directly to releases

2021-04-05 Richard Hartmann <[email protected]>

Expand Down
24 changes: 24 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ AC_DEFUN([AX_PROGVAR], [
test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required])
])

AC_ARG_WITH([standalone],
AS_HELP_STRING([--with-standalone],
[Use configuration presets for a standalone script deployment @<:@default=no@:>@]),
[COMM=comm GIT=git GREP=grep SED=sed SHELL=/bin/sh
with_deployment=standalone
with_man_page=no
enable_tests=no
with_bash_completion_dir=no
with_zsh_completion_dir=no
program_suffix=-standalone.sh
# By this point program_suffix has already been processed so we have to redo what configure did
# Code copied from approx L2670-2671
program_transform_name="s&\$&$program_suffix&;$program_transform_name"
program_transform_name=`printf "%s\n" "$program_transform_name" | sed "$ac_script"`
],
[])

AC_PROG_AWK
AC_PROG_GREP
AC_PROG_SED
Expand All @@ -18,6 +35,13 @@ AX_PROGVAR([comm])
AX_PROGVAR([cmp])
AX_PROGVAR([git])

AC_ARG_WITH([deployment],
AS_HELP_STRING([--with-deployment],
[Add deployment string to version @<:@default=@:>@]),
[],
[with_deployment=])
AC_SUBST([DEPLOYMENT], [${with_deployment:+-$with_deployment}])

AC_ARG_WITH([man-page],
AS_HELP_STRING([--with-man-page],
[Generate man page @<:@default=yes@:>@]),
Expand Down
26 changes: 26 additions & 0 deletions doc/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Many distributions have packages ready to go.
If yours doesn't, you can install [from source](#installing-from-source).
VCSH can also be deployed as a [standalone script](#standalone-script).
If you package VCSH for a distro please let us know.

## Arch Linux
Expand Down Expand Up @@ -124,4 +125,29 @@ $ make DESTDIR="$HOME" install-exec

This will install to `~/bin/vcsh`; add `~/bin` to your path to use.

# Standalone Script

A special variant of VCSH can be deployed as a single POSIX shell script with no configure/build step.
Deploying it this way leaves you without any man page or shell completion functions (or possibly with mismatched resources installed by your package manager for a different vcsh version).
This variant is also dependent or your `$PATH` to have proper versions of dependencies such as `git`.
If your user space has different tools by default than your system beware!

The standalone variant can be downloaded from any recent entry in [releases](https://github.com/RichiH/vcsh/releases).

This method is suited for installation to a user space where you don't have control over the system packages, e.g.:

```console
$ mkdir ~/bin
$ curl -fsLS https://github.com/RichiH/vcsh/releases/latest/download/vcsh-standalone.sh -O ~/bin/vcsh
$ chmod 755 ~/bin/vcsh
```

It could also be used to directly bootstrap a dotfiles repository with something like this:

```console
$ sh <(curl -fsLS https://github.com/RichiH/vcsh/releases/latest/download/vcsh-standalone.sh) clone <path_to_your_dotfiles_repo> dotfiles
```

While we are enabling cURL-based workflows on purpose, we still encourage you to avoid them where reasonably possible. If you do use it, please consider using a tagged version that you've tested to work for you instead of the "latest" keyword.

[1]: http://rtomayko.github.io/ronn/
9 changes: 5 additions & 4 deletions vcsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@


# If '.r<N>-g<SHA>' is appended to the version, you are seeing an unreleased
# version of vcsh; the main branch is supposed to be clean at all times
# so you can most likely just use it nonetheless
VCSH_VERSION='@VERSION@'; export VCSH_VERSION
VCSH_SELF="@TRANSFORMED_PACKAGE_NAME@"; export VCSH_SELF
# version built from the main branch HEAD. If "-standalone" is appended you are
# using a version built explicitly for portability as a standalone script
# rather than being installed to a specific system.
VCSH_VERSION='@VERSION@@DEPLOYMENT@'; export VCSH_VERSION
VCSH_SELF='@TRANSFORMED_PACKAGE_NAME@'; export VCSH_SELF

# Ensure all files created are accessible only to the current user.
umask 0077
Expand Down

0 comments on commit 4f013c3

Please sign in to comment.