Skip to content

Commit fa4e6ef

Browse files
committed
release: v0.1
1 parent 2430e1b commit fa4e6ef

4 files changed

Lines changed: 376 additions & 39 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: ice-release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch: {}
7+
8+
env:
9+
GO_VERSION: '1.21'
10+
BINARY_NAME: ice
11+
12+
jobs:
13+
build-matrix:
14+
name: build (${{ matrix.os }} ${{ matrix.goos }}-${{ matrix.goarch }})
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: ubuntu-latest
21+
goos: linux
22+
goarch: amd64
23+
- os: ubuntu-latest
24+
goos: linux
25+
goarch: arm64
26+
- os: macos-latest
27+
goos: darwin
28+
goarch: amd64
29+
- os: macos-latest
30+
goos: darwin
31+
goarch: arm64
32+
- os: windows-latest
33+
goos: windows
34+
goarch: amd64
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
41+
- uses: actions/setup-go@v4
42+
with:
43+
go-version: ${{ env.GO_VERSION }}
44+
45+
- name: Tidy modules
46+
run: go mod tidy
47+
48+
- name: Build
49+
run: |
50+
mkdir -p dist
51+
EXT=""
52+
if [ "${{ matrix.goos }}" = "windows" ]; then EXT=".exe"; fi
53+
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o dist/${{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${EXT} ./cmd/ice
54+
55+
- name: Compress (tar/zip)
56+
run: |
57+
cd dist
58+
for f in *; do
59+
case "$f" in
60+
*.exe) 7z a ${f%.exe}.zip $f >/dev/null ;;
61+
*) tar -czf $f.tar.gz $f ;;
62+
esac
63+
done
64+
65+
- name: Upload artifacts
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: ice-${{ matrix.goos }}-${{ matrix.goarch }}
69+
path: dist/*
70+
if-no-files-found: error
71+
72+
release:
73+
needs: build-matrix
74+
if: startsWith(github.ref, 'refs/heads/main') && contains(github.event.head_commit.message, 'release:')
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: write
78+
steps:
79+
- uses: actions/checkout@v4
80+
with:
81+
fetch-depth: 0
82+
83+
- name: Determine version
84+
id: ver
85+
run: |
86+
# Extract version after 'release: ' prefix or fallback to date
87+
msg='${{ github.event.head_commit.message }}'
88+
if echo "$msg" | grep -qi 'release:'; then
89+
ver=$(echo "$msg" | sed -E 's/.*release: *([vV]?[0-9][^ ]*).*/\1/' | sed 's/^v//')
90+
else
91+
ver=$(date +%Y.%m.%d)
92+
fi
93+
echo "version=$ver" >> $GITHUB_OUTPUT
94+
echo "Release version: $ver"
95+
96+
- name: Download artifacts
97+
uses: actions/download-artifact@v4
98+
with:
99+
path: artifacts
100+
101+
- name: Prepare release directory
102+
run: |
103+
mkdir -p release
104+
find artifacts -type f -maxdepth 3 -print -exec cp {} release/ \;
105+
ls -lah release
106+
107+
- name: Generate checksums
108+
run: |
109+
cd release
110+
sha256sum * > SHA256SUMS.txt || shasum -a 256 * > SHA256SUMS.txt
111+
112+
- name: Create GitHub Release
113+
uses: softprops/action-gh-release@v1
114+
with:
115+
tag_name: v${{ steps.ver.outputs.version }}
116+
name: "Ice v${{ steps.ver.outputs.version }}"
117+
generate_release_notes: true
118+
files: |
119+
release/*
120+
env:
121+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/update-aur.yml

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: Update AUR Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag_name:
9+
description: 'Release tag name (e.g., v1.2.3)'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
update-aur:
15+
runs-on: ubuntu-latest
16+
if: github.repository == 'Wraient/curd'
17+
18+
steps:
19+
- name: Checkout main repository
20+
uses: actions/checkout@v4
21+
22+
- name: Extract version from tag
23+
id: version
24+
run: |
25+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
26+
TAG_NAME="${{ github.event.inputs.tag_name }}"
27+
else
28+
TAG_NAME="${{ github.event.release.tag_name }}"
29+
fi
30+
VERSION=$(echo "$TAG_NAME" | sed 's/^v//')
31+
echo "version=$VERSION" >> $GITHUB_OUTPUT
32+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
33+
echo "Extracted version: $VERSION"
34+
35+
- name: Install dependencies
36+
run: |
37+
sudo apt-get update
38+
sudo apt-get install -y expect git sshpass
39+
40+
- name: Set up SSH for AUR
41+
run: |
42+
mkdir -p ~/.ssh
43+
# Write the SSH key
44+
cat > ~/.ssh/aur_rsa << 'EOF'
45+
${{ secrets.AUR_SSH_KEY }}
46+
EOF
47+
chmod 600 ~/.ssh/aur_rsa
48+
49+
# Add AUR host key
50+
ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts
51+
52+
# Test the key directly (this should prompt for passphrase)
53+
echo "Testing SSH key..."
54+
expect -c "
55+
set timeout 30
56+
spawn ssh -o PasswordAuthentication=no -o IdentitiesOnly=yes -i ~/.ssh/aur_rsa -T aur@aur.archlinux.org
57+
expect {
58+
\"Enter passphrase*\" {
59+
send \"sex\r\"
60+
expect {
61+
\"Welcome to AUR*\" {
62+
puts \"SUCCESS: SSH connection works\"
63+
exit 0
64+
}
65+
\"Permission denied*\" {
66+
puts \"ERROR: Permission denied after passphrase\"
67+
exit 1
68+
}
69+
timeout {
70+
puts \"ERROR: Timeout after passphrase\"
71+
exit 1
72+
}
73+
}
74+
}
75+
\"Welcome to AUR*\" {
76+
puts \"SUCCESS: SSH works without passphrase\"
77+
exit 0
78+
}
79+
\"Permission denied*\" {
80+
puts \"ERROR: Permission denied - wrong key or not authorized\"
81+
exit 1
82+
}
83+
timeout {
84+
puts \"ERROR: Connection timeout\"
85+
exit 1
86+
}
87+
}
88+
"
89+
90+
- name: Clone AUR repository
91+
run: |
92+
# Use expect to handle the passphrase during git clone
93+
expect -c "
94+
set timeout 60
95+
spawn git clone ssh://aur@aur.archlinux.org/curd.git aur-curd
96+
expect {
97+
\"Enter passphrase*\" {
98+
send \"sex\r\"
99+
exp_continue
100+
}
101+
\"Cloning into*\" {
102+
puts \"Clone started successfully\"
103+
exp_continue
104+
}
105+
\"Permission denied*\" {
106+
puts \"ERROR: Permission denied\"
107+
exit 1
108+
}
109+
eof {
110+
puts \"Clone completed\"
111+
exit 0
112+
}
113+
timeout {
114+
puts \"ERROR: Clone timeout\"
115+
exit 1
116+
}
117+
}
118+
"
119+
120+
# Verify the clone worked
121+
if [ -d "aur-curd" ]; then
122+
echo "SUCCESS: AUR repository cloned"
123+
ls -la aur-curd/
124+
else
125+
echo "ERROR: Clone failed"
126+
exit 1
127+
fi
128+
129+
- name: Update PKGBUILD
130+
working-directory: aur-curd
131+
run: |
132+
# Configure git
133+
git config user.name "Wraient"
134+
git config user.email "rushikeshwastaken@gmail.com"
135+
136+
# Update pkgver in PKGBUILD
137+
sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.version }}/" PKGBUILD
138+
139+
# Reset pkgrel to 1 for new version
140+
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
141+
142+
# Update .SRCINFO
143+
makepkg --printsrcinfo > .SRCINFO
144+
145+
echo "Updated PKGBUILD:"
146+
cat PKGBUILD
147+
148+
- name: Verify release exists
149+
run: |
150+
# Check if the release and binary exist
151+
curl -f -L -I "https://github.com/Wraient/curd/releases/download/${{ steps.version.outputs.tag_name }}/curd-linux-x86_64" || {
152+
echo "Error: Release binary not found!"
153+
echo "Expected URL: https://github.com/Wraient/curd/releases/download/${{ steps.version.outputs.tag_name }}/curd-linux-x86_64"
154+
exit 1
155+
}
156+
157+
- name: Commit and push to AUR
158+
working-directory: aur-curd
159+
run: |
160+
# Check if there are changes to commit
161+
if git diff --quiet && git diff --cached --quiet; then
162+
echo "No changes to commit"
163+
exit 0
164+
fi
165+
166+
# Add and commit changes
167+
git add PKGBUILD .SRCINFO
168+
git commit -m "Update to version ${{ steps.version.outputs.version }}"
169+
170+
# Push with expect to handle passphrase
171+
expect -c "
172+
set timeout 60
173+
spawn git push origin master
174+
expect {
175+
\"Enter passphrase*\" {
176+
send \"sex\r\"
177+
exp_continue
178+
}
179+
\"Everything up-to-date*\" {
180+
puts \"Nothing to push\"
181+
exit 0
182+
}
183+
\"Permission denied*\" {
184+
puts \"ERROR: Permission denied during push\"
185+
exit 1
186+
}
187+
eof {
188+
puts \"Push completed\"
189+
exit 0
190+
}
191+
timeout {
192+
puts \"ERROR: Push timeout\"
193+
exit 1
194+
}
195+
}
196+
"
197+
198+
- name: Cleanup
199+
if: always()
200+
run: |
201+
# Clean up SSH keys
202+
rm -f ~/.ssh/aur_rsa

cmd/ice/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ func main() {
175175
pickOpts := map[string]string{"r": "Resume current episode"}
176176
for _, ep := range acerShow.EpisodesList {
177177
marker := ""
178-
if ep.ID == show.EpisodeID { marker = " *" }
178+
if ep.ID == show.EpisodeID {
179+
marker = " *"
180+
}
179181
pickOpts[ep.ID] = fmt.Sprintf("S%02dE%02d %s%s", ep.Season, ep.Episode, ep.Name, marker)
180182
}
181183
choice, err := internal.DynamicSelect(pickOpts)

0 commit comments

Comments
 (0)