summaryrefslogtreecommitdiffstats
path: root/.github/workflows/release.yml
blob: e675d789fb3bc2b0407aa944efabf47ca8ca25aa (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
---
# Workflow for triggering a release.
name: Release
on:
  schedule:
    - cron: '0 0 * * *'
  workflow_dispatch: # Dispatch runs build and validate, then push to the appropriate storage location.
    inputs:
      type:
        description: Build Type
        default: nightly
        required: true
      version:
        description: Version Tag
        default: nightly
        required: true
concurrency: # This keeps multiple instances of the job from running concurrently for the same ref and event type.
  group: release-${{ github.ref }}-${{ github.event_name }}
  cancel-in-progress: true
jobs:
  update-changelogs:
    name: Update changelog
    runs-on: ubuntu-latest
    outputs:
      ref: ${{ steps.target.outputs.ref }}
      version: ${{ steps.target.outputs.version }}
      type: ${{ steps.target.outputs.type }}
      run: ${{ steps.target.outputs.run }}
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          submodules: recursive
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
      - name: Prepare base ref
        id: target
        run: >-
          .github/scripts/prepare-release-base.sh \
              ${{ github.repository }} \
              ${{ github.event_name }} \
              ${{ github.event.inputs.type }} \
              ${{ github.event.inputs.version }} \
              ${{ secrets.NETDATA_RELEASE_TEST }}
      - name: Generate Nightly Changleog
        id: nightly-changelog
        if: steps.target.outputs.run == 'true' && steps.target.outputs.type == 'nightly'
        uses: heinrichreimer/github-changelog-generator-action@v2.3
        with:
          bugLabels: IGNOREBUGS
          excludeLabels: "stale,duplicate,question,invalid,wontfix,discussion,no changelog"
          issues: false
          sinceTag: v1.10.0
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
          unreleasedLabel: "**Next release**"
          verbose: true
          maxIssues: 500
      - name: Generate Release Changelog
        id: release-changelog
        if: steps.target.outputs.run == 'true' && steps.target.outputs.type != 'nightly'
        uses: heinrichreimer/github-changelog-generator-action@v2.3
        with:
          bugLabels: IGNOREBUGS
          excludeLabels: "stale,duplicate,question,invalid,wontfix,discussion,no changelog"
          futureRelease: ${{ github.event.inputs.version }}
          issues: false
          sinceTag: v1.10.0
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
          unreleasedLabel: "**Next release**"
          verbose: true
          maxIssues: 500
      - name: Commit Changes
        id: commit
        if: steps.target.outputs.run == 'true'
        env:
          GITHUB_TOKEN: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
        run: |
          git config user.name "netdatabot"
          git config user.email "bot@netdata.cloud"
          git add packaging/version CHANGELOG.md
          git commit -m "[ci skip] ${{ steps.target.outputs.message }}"
          if [ "${{ steps.target.outputs.type }}" != "nightly" ]; then
            git tag -a "${{ github.event.inputs.version }}" -m "${{ steps.target.outputs.message }}"
          fi
          if [ -n "${{ steps.target.outputs.new-branch }}" ]; then
            git branch "${{ steps.target.outputs.new-branch }}"
          fi
          git push --tags origin "${{ steps.target.outputs.branch }}"
          if [ -n "${{ steps.target.outputs.new-branch }}" ]; then
            git push origin "${{ steps.target.outputs.new-branch }}"
          fi
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Failed to prepare changelog:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Failed to prepare changelog.
              Checkout: ${{ steps.checkout.outcome }}
              Prepare base ref: ${{ steps.target.outcome }}
              Generate nightly changelog: ${{ steps.nightly-changelog.outcome }}
              Generate release changelog: ${{ steps.release-changelog.outcome }}
              Commit changes: ${{ steps.commit.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: failure()

  trigger-artifacts:
    name: Trigger artifact builds
    runs-on: ubuntu-latest
    needs: update-changelogs
    if: needs.update-changelogs.outputs.run == 'true'
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3
        with:
          ref: ${{ needs.update-changelogs.outputs.ref }}
      - name: Trigger build
        id: trigger
        uses: benc-uk/workflow-dispatch@v1
        with:
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
          repo: ${{ github.repository }}
          workflow: build.yml
          ref: ${{ needs.update-changelogs.outputs.ref }}
          inputs: '{"version": "${{ needs.update-changelogs.outputs.version }}", "type": "${{ needs.update-changelogs.outputs.type }}"}'
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Failed to trigger ${{ needs.update-changelogs.outputs.type }} artifact builds:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Failed to trigger ${{ needs.update-changelogs.outputs.type }} artifact builds.
              Checkout: ${{ steps.checkout.outcome }}
              Trigger build: ${{ steps.trigger.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: failure()

  trigger-docker:
    name: Trigger docker builds
    runs-on: ubuntu-latest
    needs: update-changelogs
    if: needs.update-changelogs.outputs.run == 'true'
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3
        with:
          ref: ${{ needs.update-changelogs.outputs.ref }}
      - name: Trigger build
        id: trigger
        uses: benc-uk/workflow-dispatch@v1
        with:
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
          repo: ${{ github.repository }}
          workflow: docker.yml
          ref: ${{ needs.update-changelogs.outputs.ref }}
          inputs: '{"version": "${{ needs.update-changelogs.outputs.version }}"}'
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Failed to trigger ${{ needs.update-changelogs.outputs.type }} Docker builds:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Failed to trigger ${{ needs.update-changelogs.outputs.type }} Docker builds.
              Checkout: ${{ steps.checkout.outcome }}
              Trigger build: ${{ steps.trigger.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: failure()

  trigger-packages:
    name: Trigger package builds
    runs-on: ubuntu-latest
    needs: update-changelogs
    if: needs.update-changelogs.outputs.run == 'true'
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3
        with:
          ref: ${{ needs.update-changelogs.outputs.ref }}
      - name: Trigger build
        id: trigger
        uses: benc-uk/workflow-dispatch@v1
        with:
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
          repo: ${{ github.repository }}
          workflow: packaging.yml
          ref: ${{ needs.update-changelogs.outputs.ref }}
          inputs: '{"version": "${{ needs.update-changelogs.outputs.version }}", "type": "${{ needs.update-changelogs.outputs.type }}"}'
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Failed to trigger ${{ needs.update-changelogs.outputs.type }} package builds:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Failed to trigger ${{ needs.update-changelogs.outputs.type }} package builds.
              Checkout: ${{ steps.checkout.outcome }}
              Trigger build: ${{ steps.trigger.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: failure()