-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (117 loc) · 6 KB
/
Copy pathsync-sources.yml
File metadata and controls
122 lines (117 loc) · 6 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Sync source repositories
on:
schedule:
- cron: '17,47 * * * *'
workflow_dispatch:
push:
branches: [main]
pull_request:
paths:
- 'scripts/sync-sources.py'
- 'core/tabs/commander/catalog*'
- 'core/tabs/commander/catalogs/**'
- 'core/tabs/commander/generated/**'
- 'tests/test_source_sync.py'
- '.github/workflows/sync-sources.yml'
permissions:
contents: read
concurrency:
group: source-sync-${{ github.event.pull_request.number || 'main' }}
cancel-in-progress: false
jobs:
sync:
if: github.repository == 'Commanderx-code/commander-toolbox' && github.event_name != 'pull_request'
runs-on: ubuntu-22.04
timeout-minutes: 30
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: main
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Adopt sources with successful CI
id: sync
env:
GH_TOKEN: ${{ github.token }}
run: python3 -B scripts/sync-sources.py
- name: Check whether the current revision has a build
id: release
env:
GH_TOKEN: ${{ github.token }}
run: |
revision=$(git rev-parse HEAD)
if [ "$(gh release view "toolbox-${revision:0:12}" --json isDraft --jq .isDraft 2>/dev/null)" = false ]; then
echo 'exists=true' >> "$GITHUB_OUTPUT"
else
echo 'exists=false' >> "$GITHUB_OUTPUT"
fi
- name: Install validation tools
if: steps.sync.outputs.changed == 'true' || steps.release.outputs.exists != 'true' || github.event_name != 'schedule'
run: sudo apt-get update && sudo apt-get install -y shellcheck devscripts python3 fish
- name: Validate and build without installation
if: steps.sync.outputs.changed == 'true' || steps.release.outputs.exists != 'true' || github.event_name != 'schedule'
run: |
rustup toolchain install stable --profile minimal
rustup default stable
python3 -B -m unittest discover -s tests -v
shellcheck core/tabs/commander/common.sh core/tabs/commander/catalog-install.sh core/tabs/commander/terminal-tool.sh core/tabs/commander/netwatch.sh core/tabs/commander/tfm.sh core/tabs/commander/cassette.sh
checkbashisms core/tabs/commander/catalog-install.sh core/tabs/commander/terminal-tool.sh core/tabs/commander/netwatch.sh core/tabs/commander/tfm.sh core/tabs/commander/cassette.sh
cargo test --locked --no-fail-fast --package linutil_core
cargo xtask docgen
git diff --check
cargo build --locked --release --package linutil_tui
target/release/commander-toolbox --help >/dev/null
- name: Commit tested source updates
if: steps.sync.outputs.changed == 'true'
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add core/tabs/commander/common.sh core/tabs/commander/catalogs core/tabs/applications-setup/tab_data.toml docs/content/userguide/walkthrough.md
git add -A core/tabs/commander/generated
git commit -m 'Sync tested dotfiles and Myfish sources'
# A concurrent human push stops this run; never force or publish an unpushed build.
git push origin HEAD:main
- name: Publish the tested Linux x86_64 build
if: steps.sync.outputs.changed == 'true' || steps.release.outputs.exists != 'true' || github.event_name != 'schedule'
env:
GH_TOKEN: ${{ github.token }}
run: |
revision=$(git rev-parse HEAD)
tag="toolbox-${revision:0:12}"
mkdir -p /tmp/toolbox-release
cp target/release/commander-toolbox /tmp/toolbox-release/commander-toolbox-linux-x86_64
python3 -B scripts/sync-sources.py --render
git diff --exit-code
cd /tmp/toolbox-release
sha256sum commander-toolbox-linux-x86_64 > SHA256SUMS
printf 'Automatic build from Toolbox commit %s.\n\nLinux x86_64; built on Ubuntu 22.04 (glibc 2.35 or newer).\nUpdate Toolbox, then run the desired installer to apply configuration changes.\n' "$revision" > release-notes.md
# Draft first: a failed upload never exposes a partial release as the latest build.
if ! gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release create "$tag" --repo "$GITHUB_REPOSITORY" --target "$revision" --draft --title "Toolbox ${revision:0:12}" --notes-file release-notes.md
fi
gh release upload "$tag" commander-toolbox-linux-x86_64 SHA256SUMS --clobber --repo "$GITHUB_REPOSITORY"
gh release edit "$tag" --draft=false --latest --repo "$GITHUB_REPOSITORY"
validate-pr:
if: github.event_name == 'pull_request'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- run: sudo apt-get update && sudo apt-get install -y shellcheck devscripts python3 fish
- run: |
rustup toolchain install stable --profile minimal
rustup default stable
python3 -B -m unittest discover -s tests -v
python3 -B scripts/sync-sources.py --render
cargo test --locked --no-fail-fast --package linutil_core
cargo xtask docgen
git diff --exit-code
shellcheck core/tabs/commander/common.sh core/tabs/commander/catalog-install.sh core/tabs/commander/terminal-tool.sh core/tabs/commander/netwatch.sh core/tabs/commander/tfm.sh core/tabs/commander/cassette.sh
checkbashisms core/tabs/commander/catalog-install.sh core/tabs/commander/terminal-tool.sh core/tabs/commander/netwatch.sh core/tabs/commander/tfm.sh core/tabs/commander/cassette.sh