Skip to content

Commit 196b6e9

Browse files
committed
Daily build
1 parent af41200 commit 196b6e9

4 files changed

Lines changed: 110 additions & 165 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Check Upstream Releases
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *' # Run daily at 6 AM UTC
6+
workflow_dispatch: # Allow manual trigger
7+
8+
jobs:
9+
check-upstream:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
ref: stable
21+
22+
- name: Get latest upstream tag
23+
id: upstream
24+
run: |
25+
# Fetch tags from upstream repository
26+
LATEST_TAG=$(git ls-remote --tags --sort=-v:refname \
27+
https://github.com/lemonade-sdk/lemonade.git \
28+
| grep -oP 'refs/tags/\K[^{}]+$' \
29+
| head -n 1)
30+
31+
echo "Latest upstream tag: $LATEST_TAG"
32+
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
33+
34+
- name: Get current source-tag from snapcraft.yaml
35+
id: current
36+
run: |
37+
# Extract current source-tag if it exists
38+
CURRENT_TAG=$(grep -oP '^\s+source-tag:\s*\K.*' snap/snapcraft.yaml || echo "")
39+
echo "Current source-tag: $CURRENT_TAG"
40+
echo "tag=$CURRENT_TAG" >> $GITHUB_OUTPUT
41+
42+
- name: Check if update is needed
43+
id: check
44+
run: |
45+
if [ "${{ steps.upstream.outputs.tag }}" != "${{ steps.current.outputs.tag }}" ]; then
46+
echo "Update needed: ${{ steps.current.outputs.tag }} -> ${{ steps.upstream.outputs.tag }}"
47+
echo "update_needed=true" >> $GITHUB_OUTPUT
48+
else
49+
echo "Already up to date"
50+
echo "update_needed=false" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Update snapcraft.yaml
54+
if: steps.check.outputs.update_needed == 'true'
55+
run: |
56+
NEW_TAG="${{ steps.upstream.outputs.tag }}"
57+
58+
# Check if source-tag already exists in the lemonade part
59+
if grep -q '^\s\+source-tag:' snap/snapcraft.yaml; then
60+
# Update existing source-tag
61+
sed -i "s/^\(\s\+source-tag:\s*\).*/\1$NEW_TAG/" snap/snapcraft.yaml
62+
else
63+
# Add source-tag after source-subdir line in lemonade part
64+
sed -i "/^\s\+source-subdir: src\/app/a\\ source-tag: $NEW_TAG" snap/snapcraft.yaml
65+
fi
66+
67+
echo "Updated snapcraft.yaml to use tag: $NEW_TAG"
68+
cat snap/snapcraft.yaml
69+
70+
- name: Create Pull Request
71+
if: steps.check.outputs.update_needed == 'true'
72+
uses: peter-evans/create-pull-request@v6
73+
with:
74+
token: ${{ secrets.GITHUB_TOKEN }}
75+
commit-message: "Update to upstream ${{ steps.upstream.outputs.tag }}"
76+
title: "Update to upstream ${{ steps.upstream.outputs.tag }}"
77+
body: |
78+
Automated update to track upstream release.
79+
80+
**Changes:**
81+
- Updated source-tag from `${{ steps.current.outputs.tag }}` to `${{ steps.upstream.outputs.tag }}`
82+
83+
**Upstream release:**
84+
https://github.com/lemonade-sdk/lemonade/releases/tag/${{ steps.upstream.outputs.tag }}
85+
branch: update-upstream-${{ steps.upstream.outputs.tag }}
86+
delete-branch: true

.github/workflows/check-upstream.yml

Lines changed: 0 additions & 162 deletions
This file was deleted.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ jobs:
1010
build-amd64:
1111
runs-on: ubuntu-24.04
1212
steps:
13-
- uses: jlumbroso/free-disk-space@3e0187054f9c4bc1f55a743792872df36b2d88e0
14-
with:
15-
tool-cache: true
1613
- uses: actions/checkout@v4
1714
with:
1815
fetch-depth: 0

.github/workflows/snap-daily.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Snap Daily Build
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *' # Run daily at 6 AM UTC
6+
workflow_dispatch: # Allow manual trigger
7+
8+
jobs:
9+
stable:
10+
runs-on: ubuntu-24.04
11+
if: github.ref == 'refs/heads/main' # Run only for the 'main' branch
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
fetch-tags: true
17+
- uses: canonical/action-build@v1.3.0
18+
id: build
19+
- uses: snapcore/action-publish@v1
20+
env:
21+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
22+
with:
23+
snap: ${{ steps.build.outputs.snap }}
24+
release: edge

0 commit comments

Comments
 (0)