This repository was archived by the owner on Dec 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (79 loc) · 2.98 KB
/
Copy pathci.yml
File metadata and controls
79 lines (79 loc) · 2.98 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
name: CI with Smart Format Fix
on: [push, pull_request, release]
permissions:
contents: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy -- -D warnings
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
persist-credentials: true
- uses: dtolnay/rust-toolchain@stable
- run: cargo fmt --check
- name: Auto-format code
if: failure()
run: cargo fmt
- name: Get original commit message
if: failure()
id: commit_info
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
ORIGINAL_MSG=$(git log --format=%B -n 1 ${{ github.event.pull_request.head.sha }})
else
ORIGINAL_MSG=$(git log --format=%B -n 1 HEAD)
fi
echo "original_message=$ORIGINAL_MSG" >> $GITHUB_OUTPUT
- name: Commit formatting changes
if: failure()
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "${{ steps.commit_info.outputs.original_message }}-action-run-fmt-fix"
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test
release:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [lint, format, test]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build release binary
run: cargo build --release --target x86_64-unknown-linux-gnu
- name: Create release archive
run: |
mkdir -p release
cp target/x86_64-unknown-linux-gnu/release/opencode-updater release/
cd release
tar -czf opencode-updater-${{ github.event.release.tag_name }}-x86_64-linux.tar.gz opencode-updater
zip -r opencode-updater-${{ github.event.release.tag_name }}-x86_64-linux.zip opencode-updater
- name: Upload tar.gz to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./release/opencode-updater-${{ github.event.release.tag_name }}-x86_64-linux.tar.gz
asset_name: opencode-updater-${{ github.event.release.tag_name }}-x86_64-linux.tar.gz
asset_content_type: application/gzip
- name: Upload zip to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./release/opencode-updater-${{ github.event.release.tag_name }}-x86_64-linux.zip
asset_name: opencode-updater-${{ github.event.release.tag_name }}-x86_64-linux.zip
asset_content_type: application/zip