Skip to content

Commit 68b3840

Browse files
committed
feat: add semantic release and GitHub Pages deployment
1 parent 42a18dd commit 68b3840

File tree

3 files changed

+83
-13
lines changed

3 files changed

+83
-13
lines changed

.github/workflows/ci.yml

+73-13
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
6-
tags: [ 'v*' ]
5+
branches: [main]
6+
tags: ["v*"]
77
pull_request:
8-
branches: [ main ]
8+
branches: [main]
99

1010
env:
1111
CARGO_TERM_COLOR: always
@@ -16,13 +16,27 @@ permissions:
1616
jobs:
1717
test:
1818
name: Test
19-
runs-on: ubuntu-latest
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, windows-latest]
2023
steps:
2124
- uses: actions/checkout@v3
22-
- uses: dtolnay/rust-toolchain@stable
25+
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@stable
28+
2329
- uses: Swatinem/rust-cache@v2
30+
31+
- name: Install Node (Windows)
32+
if: startsWith(matrix.os, 'windows-')
33+
run: choco install nodejs-lts --no-progress
34+
35+
- name: Show Node version
36+
run: node --version || echo "No Node"
37+
2438
- name: Run tests
25-
run: cargo test
39+
run: cargo test --verbose
2640

2741
lint:
2842
name: Lint
@@ -56,6 +70,14 @@ jobs:
5670
target: aarch64-apple-darwin
5771
artifact_name: yek
5872
asset_name: yek-aarch64-apple-darwin.tar.gz
73+
- os: windows-latest
74+
target: x86_64-pc-windows-msvc
75+
artifact_name: yek.exe
76+
asset_name: yek-x86_64-pc-windows-msvc.zip
77+
- os: windows-latest
78+
target: aarch64-pc-windows-msvc
79+
artifact_name: yek.exe
80+
asset_name: yek-aarch64-pc-windows-msvc.zip
5981
steps:
6082
- uses: actions/checkout@v3
6183
- uses: dtolnay/rust-toolchain@stable
@@ -70,29 +92,67 @@ jobs:
7092
staging="yek-${{ matrix.target }}"
7193
mkdir -p "$staging"
7294
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
73-
tar czf "${{ matrix.asset_name }}" "$staging"
95+
if [[ "${{ matrix.asset_name }}" == *.zip ]]; then
96+
7z a "${{ matrix.asset_name }}" "$staging"
97+
else
98+
tar czf "${{ matrix.asset_name }}" "$staging"
99+
fi
74100
- name: Upload artifact
75101
uses: actions/upload-artifact@v3
76102
with:
77103
name: ${{ matrix.asset_name }}
78104
path: ${{ matrix.asset_name }}
79-
105+
80106
release:
81107
name: Release
82108
needs: [test, lint, build]
83109
runs-on: ubuntu-latest
84-
if: startsWith(github.ref, 'refs/tags/')
85110
steps:
111+
- uses: actions/checkout@v3
112+
with:
113+
fetch-depth: 0
114+
- name: Semantic Release
115+
uses: cycjimmy/semantic-release-action@v4
116+
id: semantic
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86119
- uses: actions/download-artifact@v3
120+
if: steps.semantic.outputs.new_release_published == 'true'
87121
with:
88122
path: artifacts
89-
- name: List artifacts
90-
run: ls -R artifacts
91123
- name: Move artifacts
124+
if: steps.semantic.outputs.new_release_published == 'true'
92125
run: |
93126
mv artifacts/*/*.tar.gz ./
94-
- name: Create Release
127+
mv artifacts/*/*.zip ./
128+
- name: Update Release with Artifacts
129+
if: steps.semantic.outputs.new_release_published == 'true'
95130
uses: softprops/action-gh-release@v1
96131
with:
132+
tag_name: v${{ steps.semantic.outputs.new_release_version }}
97133
files: |
98-
*.tar.gz
134+
*.tar.gz
135+
*.zip
136+
- name: Copy installation script to bodo.run
137+
if: steps.semantic.outputs.new_release_published == 'true'
138+
run: |
139+
git config --global user.name 'github-actions[bot]'
140+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
141+
git clone https://${{ secrets.PAT_TOKEN }}@github.com/bodo-run/bodo-run.github.io.git
142+
cp scripts/install_yek.sh bodo-run.github.io/public/yek.sh
143+
cp scripts/install_yek.ps1 bodo-run.github.io/public/yek.ps1
144+
COMMIT_SHA=$(git rev-parse HEAD)
145+
BODO_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
146+
cd bodo-run.github.io
147+
git add public/yek.sh public/yek.ps1
148+
# Exit with 0 if no changes
149+
if git diff --exit-code; then
150+
echo "No changes to commit"
151+
exit 0
152+
fi
153+
git commit -m "Update yek installation scripts" \
154+
-m "" \
155+
-m "$BODO_COMMIT_MESSAGE" \
156+
-m "" \
157+
-m "https://github.com/bodo-run/yek/commit/$COMMIT_SHA"
158+
git push

.releaserc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/github"
7+
]
8+
}

semantic-release.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[release]
2+
auto_increment = "patch" # if no commits match, increment patch by default

0 commit comments

Comments
 (0)