Skip to content

Commit cb0178e

Browse files
committed
Do an automatic release once a day
1 parent f2a8e30 commit cb0178e

File tree

3 files changed

+72
-20
lines changed

3 files changed

+72
-20
lines changed

.github/workflows/collection.yml

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

.github/workflows/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch: {}
5+
schedule:
6+
# At 4:17am each day
7+
# If this is changed, also change the 'yesterday' variable below.
8+
- cron: '17 4 1 * *'
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-18.04
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Configure
19+
id: config
20+
run: |
21+
last="$(date --date='4:17am yesterday' '+%s')"
22+
commitdate="$(git log -1 --format='%cd' --date=unix)"
23+
authordate="$(git log -1 --format='%ad' --date=unix)"
24+
release_date=""
25+
if [ "$commitdate" -gt "$last" ] || [ "$authordate" -gt "$last" ]; then
26+
release_date="$(date '+%F')"
27+
fi
28+
printf "release_date=%s\n" "$release_date"
29+
printf "::set-output name=release-date::%s\n" "$release_date"
30+
31+
- name: Build collection
32+
run: make archives
33+
34+
- name: Create release
35+
if: ${{ steps.config.outputs.release-date != '' }}
36+
id: create_release
37+
uses: actions/create-release@v1
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
RELEASE_DATE: ${{ steps.config.outputs.release-date }}
41+
with:
42+
tag_name: v${{ env.RELEASE_DATE }}
43+
release_name: Lua Filters v${{ env.RELEASE_DATE }}
44+
draft: false
45+
prerelease: false
46+
47+
- name: Add zip archive to release
48+
uses: actions/upload-release-asset@v1
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
upload_url: ${{ steps.create_release.outputs.upload_url }}
53+
asset_path: ./.build/lua-filters.zip
54+
asset_name: lua-filters.zip
55+
asset_content_type: application/zip
56+
57+
- name: Add tar archive to release
58+
uses: actions/upload-release-asset@v1
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
with:
62+
upload_url: ${{ steps.create_release.outputs.upload_url }}
63+
asset_path: ./.build/lua-filters.tar.gz
64+
asset_name: lua-filters.tar.gz
65+
asset_content_type: application/x-gtar

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ test:
99

1010
archive: .build/lua-filters.tar.gz
1111

12+
archives: .build/lua-filters.tar.gz .build/lua-filters.zip
13+
1214
show-vars:
1315
@printf "FILTERS: %s\n" $(FILTERS)
1416
@printf "FILTER_FILES: %s\n" $(FILTER_FILES)
@@ -37,6 +39,11 @@ collection: .build/lua-filters
3739
tar -czf $@ -C .build lua-filters
3840
@printf "Archive written to '%s'\n" "$@"
3941

42+
.build/lua-filters.zip: .build/lua-filters
43+
rm -f $@
44+
(cd .build && zip -r -9 lua-filters.zip lua-filters)
45+
@printf "Archive written to '%s'\n" "$@"
46+
4047
clean:
4148
rm -rf .build
4249
$(foreach f,$(FILTERS),make -C $(f) clean;)

0 commit comments

Comments
 (0)