Skip to content

Commit 73492e5

Browse files
committed
github: Add step for release and assets
1 parent e59e255 commit 73492e5

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

.github/workflows/build.yaml

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
name: Build
22

33
on: push
4+
# schedule:
5+
# - cron: '0 1 * * *'
46

57
jobs:
8+
activity-check:
9+
runs-on: ubuntu-latest
10+
name: Check if branch is stale
11+
outputs:
12+
stale: ${{ steps.activity_check.outputs.stale }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: show latest commit
16+
run: |
17+
echo ${{ github.sha }}
18+
19+
- id: activity_check
20+
continue-on-error: true
21+
name: check latest commit is less than a day
22+
if: ${{ github.event_name == 'schedule' }}
23+
run: |
24+
test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "stale=true" >> "$GITHUB_OUTPUT"
25+
626
build:
27+
needs: activity-check
28+
if: needs.activity-check.outputs.stale != 'true'
729
runs-on: ubuntu-latest
830
steps:
9-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v3
1032

1133
- name: install dependencies
1234
run: |
@@ -22,7 +44,56 @@ jobs:
2244
- name: tarball build
2345
run: tar czvf or1ksim.tar.gz -C ./install/opt/ or1k/
2446

25-
- uses: actions/upload-artifact@v2
47+
- uses: actions/upload-artifact@v3
2648
with:
2749
name: or1ksim-nightly
2850
path: or1ksim.tar.gz
51+
52+
create-release:
53+
needs: build
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v3
57+
58+
- name: Download all artifacts to current Directory
59+
uses: actions/download-artifact@v3
60+
with:
61+
name: or1ksim-nightly
62+
63+
- name: Display structure of downloaded files
64+
run: ls -ltr
65+
66+
- name: Run Commands to Setup Env
67+
run: |
68+
DATESTAMP="$(date --utc '+%Y-%m-%d')"
69+
echo "Version: ${DATESTAMP}-nightly"
70+
71+
# Setup environment variables
72+
echo "DATESTAMP=${DATESTAMP}" >> $GITHUB_ENV
73+
echo "DATEWORD=$(date --utc '+%B %d, %Y')" >> $GITHUB_ENV
74+
shell: bash
75+
76+
- name: Create Release
77+
id: create_release
78+
uses: actions/create-release@v1
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
with:
82+
tag_name: ${{ env.DATESTAMP }}
83+
release_name: "Nightly: ${{ env.DATEWORD }}"
84+
body: |
85+
**Automated Nightly Release**
86+
${{ env.DATESTAMP }}-nightly
87+
draft: false
88+
prerelease: true
89+
90+
- name: Upload Release Asset
91+
id: upload-release-asset
92+
uses: actions/upload-release-asset@v1
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
with:
96+
upload_url: ${{ steps.create_release.outputs.upload_url }}
97+
asset_path: ./or1ksim.tar.gz
98+
asset_name: or1ksim-${{ env.DATESTAMP }}.tar.gz
99+
asset_content_type: application/gzip

0 commit comments

Comments
 (0)