-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
executable file
·72 lines (64 loc) · 2.2 KB
/
Copy pathjustfile
File metadata and controls
executable file
·72 lines (64 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# `just --list --unsorted`
default:
@just --list --unsorted
# Run local tests
test: test-pass test-fail
# Verify the action passes a PR with no merge commits
test-pass:
#!/usr/bin/env bash
set -uo pipefail
output=$(act pull_request -j forbid-merge-commits -e test/event-pull-request-pass.json 2>&1) && status=0 || status=$?
echo "$output"
if [ "$status" -ne 0 ]; then
echo "FAIL: expected the action to pass a no-merge PR, but it exited $status" >&2
exit 1
fi
if ! grep -q 'No merge commits found' <<<"$output"; then
echo "FAIL: action passed but did not report 'No merge commits found'" >&2
exit 1
fi
# Verify the action fails a PR containing a merge commit
test-fail:
#!/usr/bin/env bash
set -uo pipefail
output=$(act pull_request -j forbid-merge-commits -e test/event-pull-request-fail.json 2>&1) && status=0 || status=$?
echo "$output"
if [ "$status" -eq 0 ]; then
echo "FAIL: expected the action to detect a merge commit and fail, but it passed" >&2
exit 1
fi
if ! grep -q 'Found merge commits' <<<"$output"; then
echo "FAIL: action exited non-zero but did not report 'Found merge commits'" >&2
exit 1
fi
# Lint the action.yml file
lint-action:
yamllint action.yml
# Lint workflow files
lint-workflows:
yamllint .github/workflows/*.yml
# Lint the workflow files
lint: lint-action lint-workflows
# Run everything
precommit: test lint
# Cut a release: tag VERSION, move the floating major tag, push both, and create the GitHub release
release version: precommit
#!/usr/bin/env bash
set -euo pipefail
version='{{version}}'
tag="v${version#v}"
major="${tag%%.*}"
git fetch --quiet origin
if [ -n "$(git status --porcelain)" ]; then
echo "Working tree is not clean; commit or stash first." >&2
exit 1
fi
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then
echo "HEAD is not at origin/main; push or rebase first." >&2
exit 1
fi
git tag "$tag"
git tag --force "$major"
git push origin "$tag"
git push --force origin "$major"
gh release create "$tag" --title "$tag" --generate-notes --latest