Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevithakannan2 committed Nov 3, 2024
2 parents 7bdbbdd + 5878f4d commit 6c7ded0
Show file tree
Hide file tree
Showing 30 changed files with 444 additions and 367 deletions.
48 changes: 25 additions & 23 deletions .github/workflows/bashisms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check for bashisms
on:
pull_request:
paths:
- core/tabs/**
- 'core/tabs/**/*.sh'
merge_group:
workflow_dispatch:

Expand All @@ -15,31 +15,33 @@ jobs:
- uses: actions/checkout@v4
- run: git fetch origin ${{ github.base_ref }}

- name: Get a list of changed script files
id: get_sh_files
- name: Install devscripts
run: sudo apt-get update && sudo apt-get install -y devscripts

- name: Get changed .sh files (PR only)
id: changed-sh-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v45
with:
files: '**/*.sh'

- name: Get all .sh files (if workflow dispatched)
id: sh-files
if: github.event_name != 'pull_request'
run: |
sh_files=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs | grep '\.sh$' || true)
if [ -n "$sh_files" ]; then
echo "$sh_files" > changed_files
echo "changed=1" >> $GITHUB_OUTPUT
files=$(find . -type f -name "*.sh" | tr '\n' ' ')
echo "files=${files:-none}" >> $GITHUB_ENV
- name: Set FILES for bashism check
id: set-files
run: |
if [[ "${{ steps.changed-sh-files.outputs.any_changed }}" == 'true' ]]; then
echo "FILES=${{ steps.changed-sh-files.outputs.all_changed_files }}" >> $GITHUB_ENV
else
echo "changed=0" >> $GITHUB_OUTPUT
echo "FILES=${{ env.files }}" >> $GITHUB_ENV
fi
- name: Install devscripts
if: steps.get_sh_files.outputs.changed == 1
run: sudo apt-get update && sudo apt-get install devscripts
- name: Check for bashisms
if: steps.get_sh_files.outputs.changed == 1
run: |
echo "Running for:\n$(cat changed_files)\n"
for file in $(cat changed_files); do
if [[ -f "$file" ]]; then
checkbashisms "$file"
fi
done
- name: Remove the created file
if: steps.get_sh_files.outputs.changed == 1
run: rm changed_files
IFS=' ' read -r -a file_array <<< "$FILES"
checkbashisms "${file_array[@]}"
18 changes: 14 additions & 4 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: linutil_env
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout Repository
Expand All @@ -24,11 +28,17 @@ jobs:
run: |
echo -e "<!-- THIS FILE IS GENERATED AUTOMATICALLY. EDIT .github/CONTRIBUTING.md -->\n\n$(cat .github/CONTRIBUTING.md)" > 'docs/contributing.md'
- uses: stefanzweifel/git-auto-commit-action@v5
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit_message: Commit Contributing Guidelines
file_pattern: "docs/contributing.md"
add_options: '--force'
commit-message: Update Contributing Guidelines
title: 'docs: Update Contributing Guidelines'
body: 'Automated update of Contributing Guidelines from .github/CONTRIBUTING.md'
branch: update-contributing-guidelines
delete-branch: true
base: main
labels: documentation
token: ${{ secrets.PAT_TOKEN }}
if: success()

- name: Setup Python
Expand Down
39 changes: 4 additions & 35 deletions .github/workflows/linutil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,9 @@ jobs:
run: cargo build --target-dir=build --release --verbose --target=x86_64-unknown-linux-musl --all-features

- name: Build aarch64 binary
run: cross build --target-dir=build --release --verbose --target=aarch64-unknown-linux-musl --all-features

- name: Move binaries to build directory
run: |
mv build/x86_64-unknown-linux-musl/release/linutil build/linutil
mv build/aarch64-unknown-linux-musl/release/linutil build/linutil-aarch64
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Commit Linutil
file_pattern: "build/linutil build/linutil-aarch64"
add_options: '--force'
if: success()
cross build --target-dir=build --release --verbose --target=aarch64-unknown-linux-musl --all-features
mv ./build/aarch64-unknown-linux-musl/release/linutil ./build/aarch64-unknown-linux-musl/release/linutil-aarch64
- name: Extract Version
id: extract_version
Expand All @@ -80,32 +70,11 @@ jobs:
append_body: true
generate_release_notes: true
files: |
./build/linutil
./build/linutil-aarch64
./build/x86_64-unknown-linux-musl/release/linutil
./build/aarch64-unknown-linux-musl/release/linutil-aarch64
./start.sh
./startdev.sh
prerelease: true
env:
version: ${{ env.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Preview
run: |
echo "$(pwd)/build" >> $GITHUB_PATH
- name: Generate preview
uses: charmbracelet/[email protected]
with:
path: "docs/assets/preview.tape"

- name: Move preview
run: |
mv preview.gif docs/assets/preview.gif
- name: Upload preview
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Preview for ${{ env.version }}
file_pattern: "docs/assets/preview.gif"
add_options: "--force"
if: success()
78 changes: 78 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: LinUtil Preview

on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name'
required: true
workflow_run:
workflows: ["LinUtil Release"]
types:
- completed

jobs:
generate_preview:
runs-on: ubuntu-latest
environment: linutil_env
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Get tag name ( Workflow Run )
id: latest_tag
uses: actions/github-script@v7
if: github.event_name == 'workflow_run'
with:
script: |
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1
});
core.setOutput('result', releases.data[0].tag_name);
result-encoding: string

- name: Set tag name ( Workflow Run )
if: github.event_name == 'workflow_run'
run: echo "tag_name=${{ steps.latest_tag.outputs.result }}" >> $GITHUB_ENV

- name: Set tag name ( Workflow Dispatch )
if: ${{ github.event_name }} == 'workflow_dispatch'
run: echo "tag_name=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV

- name: Download binary
run: |
curl -LO "https://github.com/${{ github.repository }}/releases/download/${{ env.tag_name }}/linutil"
- name: Set env
run: |
chmod +x linutil
mkdir -p build
mv linutil build/linutil
echo "${{ github.workspace }}/build" >> $GITHUB_PATH
- name: Generate preview
uses: charmbracelet/[email protected]
with:
path: "docs/assets/preview.tape"

- name: Move preview
run: mv preview.gif docs/assets/preview.gif

- name: Create PR
uses: peter-evans/[email protected]
with:
commit-message: Preview for ${{ env.tag_name }}
file-pattern: "docs/assets/preview.gif"
add-options: "--force"
token: ${{ secrets.PAT_TOKEN }}
branch: feature/preview-${{ env.tag_name }}
title: "Update preview for ${{ env.tag_name }}"
body: |
Automated PR to update preview gif for version ${{ env.tag_name }}
if: success()
1 change: 1 addition & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- name: Run ShellCheck
uses: reviewdog/action-shellcheck@v1
with:
shellcheck_flags: '--source-path=${{ github.workspace }}/.shellcheckrc'
reviewdog_flags: '-fail-level=any'

shfmt:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
- run: git fetch origin ${{ github.base_ref }}

- name: Run spellcheck
uses: crate-ci/typos@v1.25.0
uses: crate-ci/typos@v1.26.0
2 changes: 2 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
external-sources=true
source=core/tabs/common-script.sh
Loading

0 comments on commit 6c7ded0

Please sign in to comment.