-
Notifications
You must be signed in to change notification settings - Fork 3
90 lines (87 loc) · 3.1 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
81
82
83
84
85
86
87
88
89
90
name: "Release"
on:
workflow_dispatch: {}
repository_dispatch:
types:
- release
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'true'
token: ${{ secrets.ORG_GITHUB_TOKEN }}
- name: Fetch All Tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Import GPG Key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Login to Public ECR
uses: docker/login-action@v3
with:
registry: public.ecr.aws
username: ${{ secrets.ECR_PUBLIC_AWS_ACCESS_KEY_ID }}
password: ${{ secrets.ECR_PUBLIC_AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
- name: Set Release Version
id: version
run: |
echo "RELEASE_VERSION=$(date +v%Y.%-m.%-d)" >> $GITHUB_OUTPUT
- name: Cache Docker Layers
run: docker pull public.ecr.aws/opslevel/cli:v2022.04.22 || true
- name: Ensure Release Does Not Exist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release delete ${{ steps.version.outputs.RELEASE_VERSION }} || true
- name: Ensure Changelog
run: |
git config user.name "OpsLevel Bots"
git config user.email "[email protected]"
if test -f ./.changes/${{ steps.version.outputs.RELEASE_VERSION }}.md
then
echo "Skip Changie..."
else
go install github.com/miniscruff/changie@latest
changie batch ${{ steps.version.outputs.RELEASE_VERSION }}
changie merge
git add .
git commit -m "Cut Release '${{ steps.version.outputs.RELEASE_VERSION }}'"
git push origin HEAD
fi
git tag -f ${{ steps.version.outputs.RELEASE_VERSION }} -m "Cut Release '${{ steps.version.outputs.RELEASE_VERSION }}'"
git push -f origin refs/tags/${{ steps.version.outputs.RELEASE_VERSION }}
- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
args: release --rm-dist --release-notes=../.changes/${{ steps.version.outputs.RELEASE_VERSION }}.md
workdir: ./src
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }}
- name: Report Release To OpsLevel
uses: opslevel/[email protected]
with:
integration_url: ${{ secrets.DEPLOY_INTEGRATION_URL }}
service: "opslevel_cli"