Skip to content

Commit d23807c

Browse files
committed
feat: merge workflows
1 parent 66306db commit d23807c

File tree

3 files changed

+165
-115
lines changed

3 files changed

+165
-115
lines changed

.github/workflows/build-debian.yml

Lines changed: 0 additions & 113 deletions
This file was deleted.

.github/workflows/docker-publish.yml

Lines changed: 160 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Publish Docker Image
1+
name: Build and Publish
22

33
on:
44
push:
@@ -18,11 +18,13 @@ env:
1818
IMAGE_NAME: ${{ github.repository }}
1919

2020
jobs:
21-
build-and-push:
21+
build-and-push-docker:
2222
runs-on: ubuntu-latest
2323
permissions:
2424
contents: read
2525
packages: write
26+
outputs:
27+
image-published: ${{ steps.push.outputs.published }}
2628

2729
steps:
2830
- name: Checkout repository
@@ -52,6 +54,7 @@ jobs:
5254
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
5355
5456
- name: Build and push Docker image
57+
id: push
5558
uses: docker/build-push-action@v5
5659
with:
5760
context: .
@@ -61,3 +64,158 @@ jobs:
6164
labels: ${{ steps.meta.outputs.labels }}
6265
cache-from: type=gha
6366
cache-to: type=gha,mode=max
67+
68+
- name: Set output
69+
id: output
70+
run: echo "published=${{ github.event_name != 'pull_request' }}" >> $GITHUB_OUTPUT
71+
72+
build-debian-packages:
73+
needs: build-and-push-docker
74+
if: github.event_name != 'pull_request'
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: write
78+
packages: read
79+
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v4
83+
84+
- name: Set up Docker Buildx
85+
uses: docker/setup-buildx-action@v3
86+
87+
- name: Log in to GitHub Container Registry
88+
uses: docker/login-action@v3
89+
with:
90+
registry: ghcr.io
91+
username: ${{ github.actor }}
92+
password: ${{ secrets.GITHUB_TOKEN }}
93+
94+
- name: Set package version
95+
id: version
96+
run: |
97+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
98+
VERSION=${GITHUB_REF#refs/tags/v}
99+
else
100+
VERSION="1.0.0-dev+$(git rev-parse --short HEAD)"
101+
fi
102+
echo "version=$VERSION" >> $GITHUB_OUTPUT
103+
echo "Package version: $VERSION"
104+
105+
- name: Update version in control file
106+
run: |
107+
sed -i "s/^Version:.*/Version: ${{ steps.version.outputs.version }}/" debian/DEBIAN/control
108+
109+
- name: Wait for image to be available
110+
run: |
111+
echo "Waiting for Docker image to be available..."
112+
sleep 10
113+
for i in {1..30}; do
114+
if docker pull ghcr.io/${{ github.repository }}:latest; then
115+
echo "Image is available!"
116+
break
117+
fi
118+
echo "Attempt $i: Image not yet available, waiting..."
119+
sleep 10
120+
done
121+
122+
- name: Build Debian package (without image)
123+
run: make build
124+
125+
- name: Rename package (without image)
126+
run: |
127+
mv swarm-cli_*.deb swarm-cli_${{ steps.version.outputs.version }}_all.deb
128+
129+
- name: Build Debian package (with bundled image)
130+
run: make build-with-image
131+
132+
- name: Rename package (with image)
133+
run: |
134+
mv swarm-cli_*.deb swarm-cli_${{ steps.version.outputs.version }}_all-with-image.deb
135+
136+
- name: Upload Debian packages as artifacts
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: swarm-cli-deb-packages-${{ steps.version.outputs.version }}
140+
path: "*.deb"
141+
retention-days: 90
142+
143+
- name: Generate release notes
144+
id: release_notes
145+
run: |
146+
cat > release_notes.md << 'EOF'
147+
## Swarm CLI Release ${{ steps.version.outputs.version }}
148+
149+
### Docker Image
150+
```bash
151+
docker pull ghcr.io/${{ github.repository }}:latest
152+
docker pull ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
153+
```
154+
155+
### Installation Options
156+
157+
**Option 1: Lightweight package (recommended)**
158+
- Download: `swarm-cli_${{ steps.version.outputs.version }}_all.deb`
159+
- Size: ~10KB
160+
- Requires internet connection to pull Docker image on first use
161+
162+
**Option 2: Self-contained package**
163+
- Download: `swarm-cli_${{ steps.version.outputs.version }}_all-with-image.deb`
164+
- Size: ~50-100MB
165+
- Includes bundled Docker image, no internet required
166+
- Perfect for offline/air-gapped environments
167+
168+
### Install
169+
```bash
170+
# Download your preferred package (lightweight)
171+
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/swarm-cli_${{ steps.version.outputs.version }}_all.deb
172+
173+
# Or download self-contained package
174+
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/swarm-cli_${{ steps.version.outputs.version }}_all-with-image.deb
175+
176+
# Install
177+
sudo apt install ./swarm-cli_${{ steps.version.outputs.version }}_all.deb
178+
```
179+
180+
### Usage
181+
```bash
182+
swarm-cli --help
183+
swarm-cli status
184+
swarm-cli upload myfile.txt
185+
```
186+
187+
### What's Changed
188+
- Docker image: `ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}`
189+
- Built from commit: ${{ github.sha }}
190+
EOF
191+
192+
- name: Create or Update Release
193+
if: startsWith(github.ref, 'refs/tags/v')
194+
uses: softprops/action-gh-release@v1
195+
with:
196+
files: |
197+
swarm-cli_${{ steps.version.outputs.version }}_all.deb
198+
swarm-cli_${{ steps.version.outputs.version }}_all-with-image.deb
199+
body_path: release_notes.md
200+
draft: false
201+
prerelease: false
202+
generate_release_notes: true
203+
make_latest: true
204+
env:
205+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
206+
207+
- name: Create Development Release
208+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
209+
uses: softprops/action-gh-release@v1
210+
with:
211+
tag_name: dev-latest
212+
name: Development Build (Latest)
213+
files: |
214+
swarm-cli_${{ steps.version.outputs.version }}_all.deb
215+
swarm-cli_${{ steps.version.outputs.version }}_all-with-image.deb
216+
body_path: release_notes.md
217+
draft: false
218+
prerelease: true
219+
make_latest: false
220+
env:
221+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,15 @@ swarm-cli status
154154

155155
## Available Tags
156156

157+
### Docker Images
157158
- `latest` - Latest build from the main branch
158159
- `v*` - Semantic version tags (e.g., `v1.0.0`)
159160
- `main` - Latest commit on main branch
160161

162+
### Debian Packages
163+
- **Stable releases**: Tagged versions (e.g., `v1.0.0`) available on the [releases page](https://github.com/metaprovide/swarm-cli/releases)
164+
- **Development builds**: Available under the `dev-latest` pre-release tag for testing latest changes
165+
161166
## Building Locally
162167

163168
### Build the Docker Image

0 commit comments

Comments
 (0)