-
Notifications
You must be signed in to change notification settings - Fork 43
113 lines (98 loc) · 4.24 KB
/
update-env-version.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
name: Update Envs Version With TAG Release
on:
pull_request:
branches:
- develop
types:
- opened
- edited
- synchronize
- reopened
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
update-env-release:
if: github.event.pull_request.head.repo.fork == false
name: Run update VERSION in every ENV on components
runs-on: ubuntu-24.04
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
private-key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
id: import_gpg
with:
gpg_private_key: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY }}
passphrase: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY_PASSWORD }}
git_committer_name: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
git_committer_email: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Install GitHub CLI
run: sudo apt-get install -y gh
- name: Fetch Latest Release
id: latest_release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
RAW_RELEASE=$(gh release list --repo $GITHUB_REPOSITORY --limit 1 --json tagName --jq '.[0].tagName')
FORMATTED_RELEASE=$(echo "$RAW_RELEASE" | sed -E 's/-[a-zA-Z0-9.]+//')
echo "Raw release: $RAW_RELEASE"
echo "Formatted release: $FORMATTED_RELEASE"
echo "::set-output name=tag::$FORMATTED_RELEASE"
- name: Fetch Env Release
id: env_release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
VERSION=$(grep '^VERSION=' ./components/ledger/.env.example | cut -d '=' -f2)
echo "LEDGER version: $VERSION"
echo "::set-output name=version::$VERSION"
- name: Update AUDIT Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/audit/.env.example
- name: Update LEDGER Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/ledger/.env.example
- name: Update TRANSACTION Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/transaction/.env.example
- name: Update MDZ Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/mdz/.env.example
- name: Update Version Choco version file install.ps1
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
TAG=${{ steps.latest_release.outputs.tag }}
sed -i "s/\$version *= *'[^']*'/\$version = '$TAG'/g" "./chocolatey/tools/chocolateyinstall.ps1"
- name: Git Diff
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
git diff
- name: Commit Changes
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
GIT_AUTHOR_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
run: |
git add .
git commit -m "chore(release): update version in .env.example to ${{ steps.latest_release.outputs.tag }}"
git push origin ${{ github.head_ref }}