-
Notifications
You must be signed in to change notification settings - Fork 8
155 lines (134 loc) · 4.7 KB
/
release.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
151
152
153
154
155
name: release
on:
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
release:
runs-on:
group: ubuntu-runners
outputs:
version: ${{ steps.clean_version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install lld and llvm
run: sudo apt-get install -y lld llvm
# TODO: Remove once https://crates.io/crates/opentelemetry-otlp is updated
# and no longer has a build requirement of `protoc``.
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: "Cocogitto release"
id: release
uses: cocogitto/cocogitto-action@v3
with:
check: true
check-latest-tag-only: true
release: true
git-user: 'github-actions[bot]'
git-user-email: "github-actions[bot]@users.noreply.github.com"
- name: "Update version in Cargo.toml"
shell: bash
run: |
version=$(echo "${{ steps.release.outputs.version }}" | sed 's/v//g')
sed "s/^version = \".*\"\$/version = \"$version\"/" ./Cargo.toml > /tmp/cargo.toml
mv /tmp/cargo.toml ./Cargo.toml
- name: "Commit version bump"
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: Bump version for release"
file_pattern: "Cargo.toml Cargo.lock"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
- name: "Install Rust toolchain (stable)"
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
- name: "Generate Changelog"
run: cog changelog --at ${{ steps.release.outputs.version }} -t full_hash > GITHUB_CHANGELOG.md
- name: "Update Github release notes"
uses: softprops/action-gh-release@v1
with:
body_path: GITHUB_CHANGELOG.md
tag_name: ${{ steps.release.outputs.version }}
token: ${{ secrets.PAT }}
- id: clean_version
run: |
version=$(echo "${{ steps.release.outputs.version }}" | sed 's/v//g')
echo "version=$version" >> $GITHUB_OUTPUT
build-container:
runs-on:
group: ubuntu-runners
strategy:
matrix:
file: [Dockerfile, slim.Dockerfile]
needs:
- release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Ensure that we get the new version from updated Cargo.toml
- name: Move to HEAD
run: |
git reset --hard HEAD
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
# Authenticate with ECR
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
- name: Set tag suffix
id: suffix
run: |
if [[ "${{ matrix.file }}" == *.* ]]; then
echo "::set-output name=suffix:::$(echo "${{ matrix.file }}" | cut -d'.' -f1)"
else
echo "::set-output name=suffix::"
fi
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ steps.login-ecr.outputs.registry }}/echo-server
ghcr.io/${{ github.repository }}
walletconnect/echo-server,enable=false
flavor: |
latest=auto
tags: |
type=semver,pattern={{version}},suffix=${{ steps.suffix.outputs.suffix }}
type=semver,pattern={{major}}.{{minor}},suffix=${{ steps.suffix.outputs.suffix }}
type=raw,value=${{ needs.release.outputs.version }},suffix=${{ steps.suffix.outputs.suffix }}
# Setup Buildkit
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build, tag, and push image
uses: docker/build-push-action@v3
with:
context: .
file: ${{ matrix.file }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max