-
-
Notifications
You must be signed in to change notification settings - Fork 758
158 lines (133 loc) Β· 4.4 KB
/
nightly.yml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Nightly Build
on:
schedule: # runs on the default branch: master
- cron: "0 2 * * *" # run at 2 AM UTC
workflow_dispatch:
jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@v4
- name: print latest_commit
run: echo ${{ github.sha }}
- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> $GITHUB_OUTPUT
call-build-workflow:
name: Call Build
needs: check_date
if: |
${{ needs.check_date.outputs.should_run != 'false' }}
&& startsWith(github.ref, 'refs/heads/master')
&& ! contains(github.head_ref, 'refs/heads/chore/')
uses: evcc-io/evcc/.github/workflows/default.yml@master
docker:
name: Publish Docker :nightly
needs:
- call-build-workflow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: refs/heads/master # force master
fetch-depth: 0
- name: Get dist from cache
uses: actions/cache/restore@v4
id: cache-dist
with:
path: dist
key: ${{ runner.os }}-${{ github.sha }}-dist
- name: Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Define tags
id: meta
uses: docker/metadata-action@v5
with:
images: evcc/evcc
tags: |
type=raw,value=nightly
type=raw,value=nightly.{{date 'YYYYMMDD'}}-{{sha}}
- name: Publish
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v6
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Delete old nightly.* tags
run: |
old_tags=$(curl -s "https://hub.docker.com/v2/repositories/evcc/evcc/tags/?page_size=100" | jq -r '.results | map(select(.name | startswith("nightly."))) | sort_by(.last_updated) | reverse | .[1:] | .[].name')
for tag in $old_tags; do
echo "Deleting tag: $tag"
curl -s -H "Authorization: Bearer ${{ secrets.DOCKER_PASS }}" -X DELETE "https://hub.docker.com/v2/repositories/evcc/evcc/tags/$tag/"
done
hassio:
name: Hassio Addon :nightly
needs:
- docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
with:
repository: evcc-io/hassio-addon
token: ${{ secrets.GH_TOKEN }}
path: ./hassio
- name: Update version
run: |
current_date=$(date +%Y%m%d)
short_sha=$(echo "${{ github.sha }}" | cut -c 1-7)
sed -i -e "s/version:.*/version: nightly.${current_date}-${short_sha}/" ./hassio/evcc-nightly/config.yaml
- name: Push
run: |
cd ./hassio
git add .
git config user.name github-actions
git config user.email [email protected]
git commit -am "Mirror evcc nightly release"
git push
apt:
name: Publish APT nightly
needs:
- call-build-workflow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
id: go
- name: Patch ASN1
run: make patch-asn1-sudo
- name: Get dist from cache
uses: actions/cache/restore@v4
id: cache-dist
with:
path: dist
key: ${{ runner.os }}-${{ github.sha }}-dist
- name: Create nightly build
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: --snapshot -f .goreleaser-nightly.yml --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Cloudsmith CLI
run: pip install --upgrade cloudsmith-cli
- name: Publish .deb to Cloudsmith
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
run: make apt-nightly