-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (72 loc) · 2.76 KB
/
release.yaml
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
name: GuardRails CLI Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "~1.18"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Set new version as environment variable
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Unprotect main branch
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
curl --silent -o /dev/null --location --request DELETE 'https://api.github.com/repos/guardrailsio/guardrails-cli/branches/main/protection' \
--header "Authorization: token $GITHUB_TOKEN" \
--header 'Accept: application/vnd.github+json' \
--header 'Content-Type: application/json' \
--data-raw ''
- name: Set new version
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
sed -i -E "s/VERSION=\".*\"/VERSION=\"${{ env.VERSION }}\"/" etc/scripts/install.sh
git config --global user.email "support@guardrails.io"
git config --global user.name "guardrailsio"
git remote set-url --push origin https://$GITHUB_TOKEN@github.com/guardrailsio/guardrails-cli.git
git checkout main
git add .
git commit -a -m "set version numbers: ${{ env.VERSION }}"
git push origin main
- name: Protect main branch
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
curl --silent -o /dev/null --location --silent -o /dev/null --request PUT 'https://api.github.com/repos/guardrailsio/guardrails-cli/branches/main/protection' \
--header "Authorization: token $GITHUB_TOKEN" \
--header 'Accept: application/vnd.github+json' \
--header 'Content-Type: application/json' \
--data-raw '{
"required_pull_request_reviews": {
"dismiss_stale_reviews": false,
"require_code_owner_reviews": false,
"require_last_push_approval": false,
"required_approving_review_count": 1
},
"restrictions": null,
"enforce_admins": false,
"required_status_checks": {
"strict": true,
"contexts": [
"guardrails/scan"
]
}
}'