-
Notifications
You must be signed in to change notification settings - Fork 3
116 lines (103 loc) · 3.73 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
---
name: Nightly Release
on:
workflow_dispatch:
schedule:
# Run builds on midnight EST on weekdays
- cron: '0 5 * * 1-5'
# prevent multiple releases from running at the same time
concurrency:
group: ${{ github.workflow_ref }}
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Create tag name
shell: bash
run: |
DATE="$(date +%d-%m-%Y)"
echo DATE=$DATE >> $GITHUB_ENV
echo TAG_NAME=nightly-$DATE >> $GITHUB_ENV
echo "RELEASE_NAME=Nightly ($DATE)" >> $GITHUB_ENV
- name: Get Cargo.toml package version
shell: bash
run: |
echo CARGO_PKG_VERSION=$(cargo pkgid | cut -d@ -f2 ) >> $GITHUB_ENV
- name: Create Draft Release
id: release
uses: ncipollo/release-action@v1
with:
allowUpdates: true # allow overwriting
updateOnlyUnreleased: true # prevent modifying any non-draft non-prerelease
removeArtifacts: true # deletes any existing artifacts when modifying
draft: true
tag: ${{ env.TAG_NAME }}
name: ${{ env.RELEASE_NAME }}
commit: ${{ github.sha }} # need commit because tag doesn't exist yet
body: |
Nightly pre-release build of `${{ github.ref_name }}` on ${{ env.DATE }}.
This build is for development purposes and not intended for production use.
outputs:
releaseId: ${{ steps.release.outputs.id }}
releaseUploadUrl: ${{ steps.release.outputs.upload_url }}
tagName: ${{ env.TAG_NAME }}
cargoPackageVersion: ${{ env.CARGO_PKG_VERSION }}
build-release:
name: Build Release
needs: create-release
uses: ./.github/workflows/build-release.yml
with:
releaseId: ${{ needs.create-release.outputs.releaseId }}
releaseUploadUrl: ${{ needs.create-release.outputs.releaseUploadUrl }}
releaseTag: ${{ needs.create-release.outputs.tagName }}
packageVersion: ${{ needs.create-release.outputs.cargoPackageVersion }}
debRevision: ${{ needs.create-release.outputs.tagName }}
rpmSnapshot: ${{ github.sha }}
test-release:
name: Test Release
needs: [create-release, build-release]
uses: ./.github/workflows/test-release.yml
with:
releaseId: ${{ needs.create-release.outputs.releaseId }}
releaseVersion: ${{ needs.create-release.outputs.tagName }}
serverUrl: https://api.staging.cloudtruth.io
secrets:
CLOUDTRUTH_API_KEY: ${{ secrets.CT_STAGING_CI_ADMIN_API_KEY }}
make-prerelease:
name: Make Pre-Release
needs: [create-release, build-release, test-release]
# run after tests but ignore if they fail
if: always() && needs.build-release.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# move new release from draft to pre-release
- uses: ncipollo/release-action@v1
with:
draft: false
prerelease: true
allowUpdates: true
omitBody: true
omitName: true
tag: ${{ needs.create-release.outputs.tagName }}
commit: ${{ github.sha }}
# rotate out old nightly releases
- uses: dev-drprasad/delete-older-releases@v0.2.0
with:
keep_latest: 2
delete_tag_pattern: nightly
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# dispatch repo event to trigger test-nightly.yml
- uses: peter-evans/repository-dispatch@v2
with:
event-type: nightly-release
client-payload: '{"tagName": "${{ needs.create-release.outputs.tagName }}"}'