blob: e4168661440d9db1a134cddd3c6a8d59342f1c9c (
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
|
image: manjarolinux/base:latest
variables:
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
before_script:
- pacman -Syu --noconfirm sed jq binutils gtk3 libxss libindicator-gtk2 nss dbus-glib libdbusmenu-gtk2 git openssh curl
- useradd -m builduser
- passwd -d builduser
- printf 'builduser ALL=(ALL) ALL\n' | tee -a /etc/sudoers
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
stages:
- find_release
- test
- release
- commit
find_release_job:
stage: find_release
script:
- rm -f build.env > /dev/null 2>&1 # clean build.env
- current_version=$(grep -Po "^pkgver=\K.*" PKGBUILD)
- version=$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | jq -r '.tag_name')
- version=${version#v} # remove the v from the version
- if [ "$current_version" != "$version" ]; then
- echo "Found version $version"
- echo "pkgver=$version" > build.env
- else
- echo "No new version"
- fi
artifacts:
reports:
dotenv: build.env
paths:
- build.env
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "schedule"'
test_job:
stage: test
script:
- if [ -z "$pkgver" ]; then echo "version variable does not exist, skipping job"; exit 0; fi
- sed -i "s/^pkgver=.*/pkgver=${pkgver}/" PKGBUILD
- su -c "cd ${CI_PROJECT_DIR} && ./test" - builduser
dependencies:
- find_release_job
artifacts:
reports:
dotenv: build.env
paths:
- PKGBUILD
- .SRCINFO
- build.env
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "schedule"'
release_job:
stage: release
script:
- if [ -z "$pkgver" ]; then echo "version variable does not exist, skipping job"; exit 0; fi
- git config --global user.email "zomundo@gmail.com"
- git config --global user.name "Mundo"
- git remote add aur ssh://aur@aur.archlinux.org/terraform-bin.git
- git fetch aur master
- git config pull.rebase true
- git branch --list
- git remote -v
- git checkout -b master
- pk_name=$(grep -Po "^pkgname=\K.*" PKGBUILD)
- pk_ver=$(grep -Po "^pkgver=\K.*" PKGBUILD)
- pk_rel=$(grep -Po "^pkgrel=\K.*" PKGBUILD)
- commit_msg="update to $pk_name ver $pk_ver, rel version $pk_rel"
- git add PKGBUILD .SRCINFO
- git commit -m "$commit_msg"
- git push aur master
dependencies:
- test_job
artifacts:
reports:
dotenv: build.env
paths:
- PKGBUILD
- .SRCINFO
- build.env
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "schedule"'
commit_job:
stage: commit
script:
- if [ -z "$pkgver" ]; then echo "version variable does not exist, skipping job"; exit 0; fi
- git config --global user.email "zomundo@gmail.com"
- git config --global user.name "Mundo"
- git remote add glab "https://oauth2:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
- git fetch glab
- git checkout -b main
- pk_name=$(grep -Po "^pkgname=\K.*" PKGBUILD)
- pk_ver=$(grep -Po "^pkgver=\K.*" PKGBUILD)
- pk_rel=$(grep -Po "^pkgrel=\K.*" PKGBUILD)
- commit_msg="update to $pk_name ver $pk_ver, rel version $pk_rel"
- git add PKGBUILD .SRCINFO
- git commit -m "$commit_msg"
- git push glab main
dependencies:
- release_job
artifacts:
reports:
dotenv: build.env
paths:
- PKGBUILD
- .SRCINFO
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "schedule"'
|