This repository has been archived by the owner on May 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
150 lines (136 loc) · 5.17 KB
/
azure-pipelines.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
trigger: none
pr: none
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: check_new_version
displayName: Check new version
jobs:
- job: detect_release
steps:
- bash: |
version=$(curl -s -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/vincent-herlemont/short/releases/latest" | \
jq -r .tag_name | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')
echo "##vso[task.setvariable variable=github_version]$version"
- bash: |
version=$(cargo metadata --no-deps --format-version 1 --manifest-path Cargo.toml \
| jq -r '.packages[] | select(.name | test("short")) | .version')
echo "##vso[task.setvariable variable=cargo_version]$version"
- bash: |
echo github_version : {$(github_version)}
echo cargo_version : {$(cargo_version)}
if [ "$(github_version)" == "$(cargo_version)" ]; then exit 1; fi;
- stage: github_release
displayName: Github
dependsOn: check_new_version
jobs:
- job: github_release
steps:
- bash: |
version=$(cargo metadata --no-deps --format-version 1 --manifest-path Cargo.toml \
| jq -r '.packages[] | select(.name | test("short")) | .version')
echo "##vso[task.setvariable variable=version]$version"
- task: GitHubRelease@1
inputs:
gitHubConnection: 'github.com_vincent-herlemont'
repositoryName: 'vincent-herlemont/short'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'userSpecifiedTag'
tag: 'v$(version)'
title: 'v$(version)'
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
- stage: crateio_release
dependsOn: github_release
displayName: Crates.io
jobs:
- job: cargo_publish
steps:
- bash: |
cargo publish --locked --token $(cargo_token)
env:
CARGO_TOKEN: $(cargo_token)
- stage: archlinux_release
displayName: AUR (archlinux)
dependsOn: crateio_release
jobs:
- job: arch_linux_release
container: vincentherl/archlinux_azure_pipelines:latest
steps:
- task: DownloadSecureFile@1
name: aurCertificate
inputs:
secureFile: aur
- bash: |
set -e
sudo pacman -S --noconfirm rust jq
version=$(cargo metadata --no-deps --format-version 1 --manifest-path Cargo.toml \
| jq -r '.packages[] | select(.name | test("short")) | .version')
cd ~
mkdir .ssh
sudo cp $(aurCertificate.secureFilePath) .ssh/
sudo chown vsts_azpcontainer:vsts_azpcontainer .ssh/aur
sudo chmod 600 .ssh/aur
cat <<DOC >> .ssh/config
Host aur.archlinux.org
HostName aur.archlinux.org
User git
AddKeysToAgent yes
IdentityFile ~/.ssh/aur
DOC
echo $(aur_known_hosts_entry) >> .ssh/known_hosts
echo .ssh/known_hosts
cat .ssh/known_hosts
echo .ssh/config
cat .ssh/config
tree -a
ls -al .ssh/
echo Arch linux release
git clone ssh://aur@aur.archlinux.org/short-git.git
cd short-git
cat $(Build.SourcesDirectory)/.releases_tpl/aur_short-git/PKGBUILD | tee PKGBUILD
makepkg -do
makepkg --printsrcinfo > .SRCINFO
git config --global user.email "$(git_user_email)"
git config --global user.name "$(git_user_name)"
git add PKGBUILD
git add .SRCINFO
git commit -m "release v$version"
git log -p -1
git push origin
- stage: homebrew_release
displayName: Homebrew (vincent-herlemont/tap/short)
dependsOn: crateio_release
jobs:
- job: homebrew_release
steps:
- bash: |
set -e
version=$(cargo metadata --no-deps --format-version 1 --manifest-path Cargo.toml \
| jq -r '.packages[] | select(.name | test("short")) | .version')
echo "Homebrew release ! (short:$version)"
cd ~
tarball_url=https://github.com/vincent-herlemont/short/archive/v$version.tar.gz
echo tarball_url $tarball_url
tarball_file=short-v$version.tar.gz
echo tarball_file $tarball_file
curl -L -o "$tarball_file" "$tarball_url"
ls -al
tarball_sha256=$(shasum -a 256 $tarball_file | awk '{print $1}')
echo tarball_sha256 $tarball_sha256
git clone "https://vincent-herlemont:$(github_token)@github.com/vincent-herlemont/homebrew-tap.git"
cd homebrew-tap/Formula
ls -al
cat $(Build.SourcesDirectory)/.releases_tpl/homebrew/short.rb | tee short.rb
sed -i.bak -E "s/^([ ]+url \").*(\")$/\1$(echo $tarball_url | sed -E 's/[]\/$*.^[]/\\&/g')\2/" short.rb
sed -i.bak -E "s/^([ ]+sha256 \").*(\")$/\1$tarball_sha256\2/" short.rb
git add short.rb
git config --global user.email "$(git_user_email)"
git config --global user.name "$(git_user_name)"
git commit -m "release v$version"
git log -p -1
git push origin
env:
GITHUB_TOKEN: $(github_token)