-
Notifications
You must be signed in to change notification settings - Fork 104
136 lines (114 loc) · 4 KB
/
release-relayer.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
name: release-relayer
on:
push:
paths:
- "relayer/**"
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: snowfork/snowbridge-relay
jobs:
release-relayer:
runs-on: snowbridge-runner
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Setup go
uses: actions/checkout@v4
with:
go-version: "^1.21.0"
- name: Install Go tools
run: >
go install github.com/magefile/[email protected] &&
go install github.com/ferranbt/fastssz/[email protected] &&
go install github.com/ethereum/go-ethereum/cmd/[email protected]
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Build contracts
working-directory: contracts
run: forge build
- name: Install dependencies
working-directory: relayer
run: go mod download
- name: Add gopath to bin
run: echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Build
working-directory: relayer
run: CGO_ENABLED=1 GOOS=linux GOARCH=amd64 mage build
- name: Configure Git
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Determine new version
id: new_version
run: |
# Get the most recent tag in the format relayer-v<version>
current_tag=$(git tag --list "relayer-v*" --sort=-v:refname | head -n 1)
current_version=$(git tag --list "relayer-v*" --sort=-v:refname | head -n 1 | sed -E 's/relayer-v//')
echo "Current version: $current_version"
# If there is no current version, set it to 1.0.0
if [ -z "$current_version" ]; then
new_version="1.0.0"
else
new_version=$(npx semver $current_version -i patch)
fi
echo "New version: $new_version"
echo "version=$new_version" >> $GITHUB_OUTPUT
echo "from_tag=$current_tag" >> $GITHUB_OUTPUT
- name: Create new tag
id: create_tag
run: |
tag_name="relayer-v${{ steps.new_version.outputs.version }}"
echo "Tag name: $tag_name"
echo "tag=$tag_name" >> $GITHUB_OUTPUT
git tag $tag_name
- name: Push new tag
run: |
git push origin --tags
- name: "Build Changelog"
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
fromTag: ${{ steps.new_version.outputs.from_tag }}
toTag: ${{ steps.create_tag.outputs.tag }}
- name: Create a GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.create_tag.outputs.tag }}
release_name: ${{ steps.create_tag.outputs.tag }}
body: |
${{steps.build_changelog.outputs.changelog}}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./relayer/build/snowbridge-relay
asset_name: snowbridge-relay
asset_content_type: application/octet-stream
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./relayer
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.create_tag.outputs.tag }}