-
Notifications
You must be signed in to change notification settings - Fork 4
154 lines (132 loc) · 8.09 KB
/
version_bump_and_new_release.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
name: Version bump the Jq, Loki, Promtail version and create a new release
on:
workflow_dispatch:
inputs:
force:
type: boolean
description: Force create the release version
default: 'false'
schedule:
- cron: "0 0 */15 * *"
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- name: Install the requirements
run: sudo apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC sudo apt install jq curl git sed nodejs make wget unzip -y
- name: Create the cache
run: mkdir /tmp/cache /tmp/loki-blobs
- name: Download Bosh CLI
run: cd /tmp/cache && curl -sL https://github.com/cloudfoundry/bosh-cli/releases/download/v${BOSH_VERSION}/bosh-cli-${BOSH_VERSION}-linux-amd64 > bosh && chmod 777 bosh
env:
BOSH_VERSION: 7.6.1
- name: Checkout the latest Loki Boshrelease
uses: actions/checkout@v4
with:
repository: cloudfoundry-community/loki-boshrelease
submodules: "recursive"
persist-credentials: false
- name: Get latest download urls
run: |
echo "LATEST_JQ_DOWNLOAD_URL=$(curl -sL https://tis-service-user:${{ secrets.TIS_PUBLIC_API_READ_TOKEN }}@api.github.com/repos/jqlang/jq/releases/latest | jq -r '.assets[].browser_download_url' | grep 'jq-linux-amd64$')" >> $GITHUB_ENV
echo "LATEST_LOKI_DOWNLOAD_URL=$(curl -sL https://tis-service-user:${{ secrets.TIS_PUBLIC_API_READ_TOKEN }}@api.github.com/repos/grafana/loki/releases/latest | jq -r '.assets[].browser_download_url' | grep 'loki-linux-amd64')" >> $GITHUB_ENV
echo "LATEST_PROMTAIL_DOWNLOAD_URL=$(curl -sL https://tis-service-user:${{ secrets.TIS_PUBLIC_API_READ_TOKEN }}@api.github.com/repos/grafana/loki/releases/latest | jq -r '.assets[].browser_download_url' | grep 'promtail-linux-amd64')" >> $GITHUB_ENV
- name: Get latest versions
run: |
echo "LATEST_JQ_VERSION=$(curl -sL https://tis-service-user:${{ secrets.TIS_PUBLIC_API_READ_TOKEN }}@api.github.com/repos/jqlang/jq/releases/latest | jq -r '.tag_name' | sed 's/jq-//')" >> $GITHUB_ENV
echo "LATEST_LOKI_VERSION=$(curl -sL https://tis-service-user:${{ secrets.TIS_PUBLIC_API_READ_TOKEN }}@api.github.com/repos/grafana/loki/releases/latest | jq -r '.tag_name' | sed 's/v//')" >> $GITHUB_ENV
echo "LATEST_PROMTAIL_VERSION=$(curl -sL https://tis-service-user:${{ secrets.TIS_PUBLIC_API_READ_TOKEN }}@api.github.com/repos/grafana/loki/releases/latest | jq -r '.tag_name' | sed 's/v//')" >> $GITHUB_ENV
- name: Set the Git safe directory
run: git config --global --add safe.directory /__w/loki-boshrelease/loki-boshrelease
- name: Identify the used versions
run: |
echo "USED_JQ_VERSION=$(cat config/blobs.yml | grep -o "jq-linux64-[[:digit:]].[[:digit:]].[[:digit:]]" | cut -d "-" -f 3)" >> $GITHUB_ENV
echo "USED_LOKI_VERSION=$(cat config/blobs.yml | grep loki | cut -d "-" -f 3 | cut -d ":" -f 1)" >> $GITHUB_ENV
echo "USED_PROMTAIL_VERSION=$(cat config/blobs.yml | grep promtail | cut -d "-" -f 3 | cut -d ":" -f 1)" >> $GITHUB_ENV
- name: Delete the blob configuration temporary
run: rm config/blobs.yml 2> /dev/null && touch config/blobs.yml
- name: Execute the version bump
run: |
curl -sL $LATEST_JQ_DOWNLOAD_URL -o /tmp/cache/jq-linux64-$LATEST_JQ_VERSION
/tmp/cache/bosh add-blob /tmp/cache/jq-linux64-$LATEST_JQ_VERSION jq-linux64-$LATEST_JQ_VERSION
curl -sL $LATEST_LOKI_DOWNLOAD_URL -o /tmp/cache/loki-linux64-$LATEST_LOKI_VERSION.zip
unzip /tmp/cache/loki-linux64-$LATEST_LOKI_VERSION.zip -d /tmp/cache
rm /tmp/cache/loki-linux64-$LATEST_LOKI_VERSION.zip
/tmp/cache/bosh add-blob /tmp/cache/loki-linux-amd64 loki-linux64-$LATEST_LOKI_VERSION
curl -sL $LATEST_PROMTAIL_DOWNLOAD_URL -o /tmp/cache/promtail-linux64-$LATEST_PROMTAIL_VERSION.zip
unzip /tmp/cache/promtail-linux64-$LATEST_PROMTAIL_VERSION.zip -d /tmp/cache
rm /tmp/cache/promtail-linux64-$LATEST_PROMTAIL_VERSION.zip
/tmp/cache/bosh add-blob /tmp/cache/promtail-linux-amd64 promtail-linux64-$LATEST_PROMTAIL_VERSION
/tmp/cache/bosh blobs
/tmp/cache/bosh upload-blobs
shell: bash
- name: Replace the used JQ version
run: sed -i -e "s/jq-linux64-$USED_JQ_VERSION/jq-linux64-$LATEST_JQ_VERSION/g" packages/jq/spec
shell: bash
- name: Replace the used Loki version
run: |
sed -i -e "s/loki-linux64-$USED_LOKI_VERSION/loki-linux64-$LATEST_LOKI_VERSION/g" packages/loki/spec
shell: bash
- name: Replace the used Promtail version
run: |
sed -i -e "s/promtail-linux64-$USED_PROMTAIL_VERSION/promtail-linux64-$LATEST_PROMTAIL_VERSION/g" packages/promtail/spec
shell: bash
- name: Check changed files
uses: tj-actions/verify-changed-files@v20
id: verify-changed-files-vendor
with:
files: |
packages
- name: Commit files
if: steps.verify-changed-files-vendor.outputs.files_changed == 'true' || inputs.force == true
continue-on-error: true
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add packages config/blobs.yml
git commit -m "Create a new loki-boshrelease"
- name: Remove the blobs
run: |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /tmp/cache/yq && sudo chmod +x /tmp/cache/yq
/tmp/cache/yq -i 'del(.builds.*)' .final_builds/jobs/loki/index.yml
/tmp/cache/yq -i 'del(.builds.*)' .final_builds/jobs/promtail/index.yml
/tmp/cache/yq -i 'del(.builds.*)' .final_builds/packages/jq/index.yml
/tmp/cache/yq -i 'del(.builds.*)' .final_builds/packages/loki/index.yml
/tmp/cache/yq -i 'del(.builds.*)' .final_builds/packages/promtail/index.yml
/tmp/cache/yq -i 'del(.builds.*)' .final_builds/license/index.yml
shell: bash
- name: Create the bosh release
id: loki-boshrelease
run: |
echo "LOKI_BOSHRELEASE_VERSION=$(/tmp/cache/bosh create-release --final --force --tarball=loki-boshrelease.tgz | sed -n '2p' | sed 's/[\t]*$//g')" >> $GITHUB_ENV
- name: Check changed files
if: steps.verify-changed-files-vendor.outputs.files_changed == 'true' || inputs.force == true
uses: tj-actions/verify-changed-files@v20
id: verify-changed-files-release
with:
files: |
.final_builds
releases/loki/index.yml
- name: Commit files
if: (steps.verify-changed-files-vendor.outputs.files_changed == 'true' && steps.verify-changed-files-release.outputs.files_changed == 'true') || inputs.force == true
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .final_builds releases/loki/index.yml "releases/loki/loki-${LOKI_BOSHRELEASE_VERSION}.yml"
git commit -m "Create loki-boshrelease version ${LOKI_BOSHRELEASE_VERSION}"
git tag -a "v${LOKI_BOSHRELEASE_VERSION}" HEAD -m "Create the new Loki release version v${LOKI_BOSHRELEASE_VERSION}"
- name: Push changes to the branch
uses: ad-m/github-push-action@master
if: (steps.verify-changed-files-vendor.outputs.files_changed == 'true' && steps.verify-changed-files-release.outputs.files_changed == 'true') || inputs.force == true
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true
force: true
- name: Create new release
uses: softprops/action-gh-release@v2
if: (steps.verify-changed-files-vendor.outputs.files_changed == 'true' && steps.verify-changed-files-release.outputs.files_changed == 'true') || inputs.force == true
with:
files: "loki-boshrelease.tgz"
tag_name: "v${{ env.LOKI_BOSHRELEASE_VERSION }}"
token: ${{ secrets.GITHUB_TOKEN }}