-
Notifications
You must be signed in to change notification settings - Fork 1
117 lines (114 loc) · 4.32 KB
/
release.yaml
File metadata and controls
117 lines (114 loc) · 4.32 KB
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
name: Close release
on:
workflow_dispatch:
inputs:
release_type:
description: "Next version type"
required: true
type: choice
default: "patch"
options:
- patch
- minor
- major
concurrency:
group: release
cancel-in-progress: false
jobs:
build-binaries:
strategy:
matrix:
binary:
- architecture: x86_64-linux
runner: ubuntu-latest
name: Binary ${{ matrix.binary.architecture }}
uses: ./.github/workflows/build-binaries.yaml
with:
branch: main
runner: ${{ matrix.binary.runner }}
architecture: ${{ matrix.binary.architecture }}
version_type: "release"
secrets: inherit
release:
name: Close release
needs:
- build-binaries
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup GCP
id: gcp
uses: hoprnet/hopr-workflows/actions/setup-gcp@master
with:
google-credentials: ${{ secrets.GCP_SA_GITHUB_ACTIONS }}
install-sdk: "true"
- name: Install Nix
uses: cachix/install-nix-action@v30
- name: Setup environment variables
id: environment
run: |
release_version=$(grep -E '^version\s*=' Cargo.toml | awk -F\" '{print $2}')
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: "gnosis_vpn-server - v${{ steps.environment.outputs.release_version }}"
tag_name: v${{ steps.environment.outputs.release_version }}
- name: Publish binaries
run: |
architectures=("x86_64-linux" )
mkdir -p binaries
for architecture in "${architectures[@]}"; do
echo "Downloading from GCP binary gnosis_vpn-${architecture}"
gcloud artifacts files download --project=gnosisvpn-production --location=europe-west3 --repository=rust-binaries gnosis_vpn:${{ steps.environment.outputs.release_version }}:gnosis_vpn-server-${architecture} --destination=./binaries --local-filename=gnosis_vpn-server-${architecture}
echo "Uploading binary gnosis_vpn-server-${architecture}"
gh release upload v${{ steps.environment.outputs.release_version }} "$PWD/binaries/gnosis_vpn-server-${architecture}" --clobber
done
env:
GH_TOKEN: ${{ github.token }}
- name: Bump Version
id: bump
shell: bash
run: |
current_version=$(grep -E '^version\s*=' Cargo.toml | awk -F\" '{print $2}')
# Extract parts without IFS or read
IFS='.' read -r major_version minor_version patch_version <<< "${current_version}"
echo "Current version $major_version $minor_version $patch_version"
# Bump the appropriate part
echo "Bumping ${{ inputs.release_type }} version"
case "${{ inputs.release_type }}" in
major)
major_version=$((major_version+1))
minor_version=0
patch_version=0
;;
minor)
minor_version=$((minor_version+1))
patch_version=0
;;
patch)
patch_version=$((patch_version+1))
;;
*)
echo "Invalid release type"
exit 1
;;
esac
echo "New version: ${major_version}.${minor_version}.${patch_version}"
bump_version="${major_version}.${minor_version}.${patch_version}"
echo "Updating version from $current_version to $bump_version"
# Update the version in Cargo.toml
# capture group 1: version = "
# capture group 2: the version number
# capture group 3: "
sed -i.bak -E "s/(^version = \")([0-9]+\.[0-9]+\.[0-9]+)(\")/\1${bump_version}\3/" Cargo.toml
rm Cargo.toml.bak
nix develop --command cargo generate-lockfile
echo "bump_version=${bump_version}" >> $GITHUB_OUTPUT
- uses: EndBug/add-and-commit@v9
with:
add: "Cargo.*"
new_branch: main
message: "Bump to version ${{ steps.bump.outputs.bump_version }}"
pathspec_error_handling: exitImmediately