Skip to content

Commit 4f013c3

Browse files
authored
Merge pull request #299 from alerque/bootstrapable
Build standalone script edition in CI
2 parents 076a000 + 5bcb2ea commit 4f013c3

File tree

8 files changed

+155
-23
lines changed

8 files changed

+155
-23
lines changed

.github/workflows/build.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
7+
standalone:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0
14+
- name: Fetch tags
15+
run: |
16+
git fetch --prune --tags ||:
17+
- name: Configure standalone script
18+
run: |
19+
./bootstrap.sh
20+
./configure --with-standalone --bindir=/
21+
make DESTDIR=. install-exec
22+
echo VERSION=$(cat .version) >> $GITHUB_ENV
23+
- name: Post standalone script artifact
24+
uses: actions/upload-artifact@v2
25+
with:
26+
name: standalone-deployment-${{ env.VERSION }}
27+
path: vcsh-standalone.sh
28+
29+
source-dist:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v2
34+
with:
35+
fetch-depth: 0
36+
- name: Fetch tags
37+
run: |
38+
git fetch --prune --tags ||:
39+
- name: Install build dependencies
40+
run: |
41+
sudo apt install -y ronn
42+
- name: Install perl test dependencies
43+
uses: perl-actions/[email protected]
44+
with:
45+
install: |
46+
Shell::Command
47+
Test::Most
48+
- name: Configure
49+
run: |
50+
./bootstrap.sh
51+
./configure
52+
- name: Run tests
53+
run: |
54+
make check
55+
- name: Build source package
56+
run: |
57+
make dist
58+
echo VERSION=$(cat .version) >> $GITHUB_ENV
59+
- name: Post build artifacts
60+
uses: actions/upload-artifact@v2
61+
with:
62+
name: vcsh-${{ env.VERSION }}
63+
path: vcsh-${{ env.VERSION }}.zip

.github/workflows/lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
name: Lint
2+
23
on: [push, pull_request]
4+
35
jobs:
6+
47
editor-config:
58
runs-on: ubuntu-latest
69
steps:
710
- name: Checkout
811
uses: actions/checkout@v2
912
- name: Lint code style
1013
uses: editorconfig-checker/[email protected]
14+
1115
shellcheck:
1216
runs-on: ubuntu-latest
1317
steps:

.github/workflows/release.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,27 @@ on:
77

88
jobs:
99

10-
ghrelase:
10+
ghrelease:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v2
15-
- name: Install ronn
15+
- name: Install build dependencies
1616
run: |
17-
sudo apt update
1817
sudo apt install -y ronn
1918
- name: Configure
2019
run: |
2120
echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
2221
echo "${GITHUB_REF#refs/*/v}" > .tarball-version
2322
./bootstrap.sh
2423
./configure
25-
- name: Build source package
26-
run: |
27-
make dist
28-
- name: Check source package behaviour
29-
run: |
30-
make distcheck
3124
- name: Make sure changelog was updated
3225
run: |
3326
make changelog-HEAD
3427
grep -F "* Release ${{ env.VERSION }}" changelog-HEAD
28+
- name: Build source package
29+
run: |
30+
make dist
3531
- name: Publish Release
3632
uses: softprops/action-gh-release@v1
3733
with:
@@ -41,3 +37,22 @@ jobs:
4137
vcsh-${{ env.VERSION }}.tar.xz
4238
env:
4339
GITHUB_TOKEN: ${{ github.token }}
40+
41+
deploy-standalone:
42+
runs-on: ubuntu-latest
43+
needs: [ ghrelease ]
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v2
47+
- name: Configure standalone script
48+
run: |
49+
echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
50+
./bootstrap.sh
51+
./configure --with-standalone --bindir=/
52+
make DESTDIR=. install-exec
53+
- name: Add standalone deployment to release
54+
uses: svenstaro/upload-release-action@v2
55+
with:
56+
repo_token: ${{ github.token }}
57+
file: vcsh-standalone.sh
58+
tag: ${{ github.ref }}

.github/workflows/test.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Test
2+
23
on: [push, pull_request]
4+
35
jobs:
6+
47
test:
58
runs-on: ubuntu-latest
69
steps:
@@ -11,9 +14,9 @@ jobs:
1114
- name: Fetch tags
1215
run: |
1316
git fetch --prune --tags ||:
14-
- name: Install dependencies
17+
- name: Install build dependencies
1518
run: |
16-
sudo apt install ronn
19+
sudo apt install -y ronn
1720
- name: Install perl test dependencies
1821
uses: perl-actions/[email protected]
1922
with:
@@ -27,12 +30,6 @@ jobs:
2730
- name: Run tests
2831
run: |
2932
make check
30-
- name: Build source package
33+
- name: Run full cycle packaging check
3134
run: |
32-
make dist
33-
echo VERSION=$(cat .version) >> $GITHUB_ENV
34-
- name: Post build artifacts
35-
uses: actions/upload-artifact@v2
36-
with:
37-
name: vcsh-${{ env.VERSION }}
38-
path: vcsh-${{ env.VERSION }}.zip
35+
make distcheck

changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ unreleased
1919
* Allow use of specific path when running Git or any dependency
2020
* Fail if hook scripts return failure codes
2121
* Check GIT_REMOTE early on clone()
22+
* Support renaming script as configuration option
23+
* Setup standalone script build profile and attach directly to releases
2224

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

configure.ac

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ AC_DEFUN([AX_PROGVAR], [
1010
test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required])
1111
])
1212

13+
AC_ARG_WITH([standalone],
14+
AS_HELP_STRING([--with-standalone],
15+
[Use configuration presets for a standalone script deployment @<:@default=no@:>@]),
16+
[COMM=comm GIT=git GREP=grep SED=sed SHELL=/bin/sh
17+
with_deployment=standalone
18+
with_man_page=no
19+
enable_tests=no
20+
with_bash_completion_dir=no
21+
with_zsh_completion_dir=no
22+
program_suffix=-standalone.sh
23+
# By this point program_suffix has already been processed so we have to redo what configure did
24+
# Code copied from approx L2670-2671
25+
program_transform_name="s&\$&$program_suffix&;$program_transform_name"
26+
program_transform_name=`printf "%s\n" "$program_transform_name" | sed "$ac_script"`
27+
],
28+
[])
29+
1330
AC_PROG_AWK
1431
AC_PROG_GREP
1532
AC_PROG_SED
@@ -18,6 +35,13 @@ AX_PROGVAR([comm])
1835
AX_PROGVAR([cmp])
1936
AX_PROGVAR([git])
2037

38+
AC_ARG_WITH([deployment],
39+
AS_HELP_STRING([--with-deployment],
40+
[Add deployment string to version @<:@default=@:>@]),
41+
[],
42+
[with_deployment=])
43+
AC_SUBST([DEPLOYMENT], [${with_deployment:+-$with_deployment}])
44+
2145
AC_ARG_WITH([man-page],
2246
AS_HELP_STRING([--with-man-page],
2347
[Generate man page @<:@default=yes@:>@]),

doc/INSTALL.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

78
## Arch Linux
@@ -124,4 +125,29 @@ $ make DESTDIR="$HOME" install-exec
124125

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

128+
# Standalone Script
129+
130+
A special variant of VCSH can be deployed as a single POSIX shell script with no configure/build step.
131+
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).
132+
This variant is also dependent or your `$PATH` to have proper versions of dependencies such as `git`.
133+
If your user space has different tools by default than your system beware!
134+
135+
The standalone variant can be downloaded from any recent entry in [releases](https://github.com/RichiH/vcsh/releases).
136+
137+
This method is suited for installation to a user space where you don't have control over the system packages, e.g.:
138+
139+
```console
140+
$ mkdir ~/bin
141+
$ curl -fsLS https://github.com/RichiH/vcsh/releases/latest/download/vcsh-standalone.sh -O ~/bin/vcsh
142+
$ chmod 755 ~/bin/vcsh
143+
```
144+
145+
It could also be used to directly bootstrap a dotfiles repository with something like this:
146+
147+
```console
148+
$ sh <(curl -fsLS https://github.com/RichiH/vcsh/releases/latest/download/vcsh-standalone.sh) clone <path_to_your_dotfiles_repo> dotfiles
149+
```
150+
151+
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.
152+
127153
[1]: http://rtomayko.github.io/ronn/

vcsh.in

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717

1818

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

2526
# Ensure all files created are accessible only to the current user.
2627
umask 0077

0 commit comments

Comments
 (0)