Skip to content

Commit a6d1a52

Browse files
committed
Fixing versioning code for release
1 parent fd35530 commit a6d1a52

File tree

6 files changed

+46
-19
lines changed

6 files changed

+46
-19
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ jobs:
4444
mkdir -p build
4545
cp yq.1 build/yq.1
4646
./scripts/xcompile.sh
47-
env:
48-
VERSION: ${{ steps.get_version.outputs.VERSION }}
4947
5048
- name: Release
5149
uses: softprops/action-gh-release@v1

.github/workflows/snap-release.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16-
17-
- name: Get the version
18-
id: get_version
19-
run: echo "VERSION=${GITHUB_REF##*/}" >> "${GITHUB_OUTPUT}"
20-
21-
- name: Update snapcraft version file
22-
env:
23-
VERSION: ${{ steps.get_version.outputs.VERSION }}
24-
uses: mikefarah/yq@master
25-
with:
26-
cmd: yq -i '.version = strenv(VERSION)' snap/snapcraft.yaml
2716
- uses: snapcore/action-build@v1
2817
id: build
2918
- uses: snapcore/action-publish@v1

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var (
1111
GitDescribe string
1212

1313
// Version is main version number that is being run at the moment.
14-
Version = ""
14+
Version = "v4.30.4"
1515

1616
// VersionPrerelease is a pre-release marker for the version. If this is "" (empty string)
1717
// then it means that it is a final release. Otherwise, this is a pre-release

scripts/bump-version.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ "$1" == "" ]; then
5+
echo "Please specify at a version"
6+
exit 1
7+
fi
8+
9+
version=$1
10+
11+
# validate version is in the right format
12+
echo $version | sed -r '/v4\.[0-9][0-9]\.[0-9][0-9]?$/!{q1}'
13+
14+
previousVersion=$(cat cmd/version.go| sed -n 's/.*Version = "\([^"]*\)"/\1/p')
15+
16+
echo "Updating from $previousVersion to $version"
17+
18+
sed -i "s/\(.*Version =\).*/\1 \"$version\"/" cmd/version.go
19+
20+
go build .
21+
actualVersion=$(./yq --version)
22+
23+
if [ "$actualVersion" != "yq (https://github.com/mikefarah/yq/) version $version" ]; then
24+
echo "Failed to update version.go"
25+
exit 1
26+
else
27+
echo "version.go updated"
28+
fi
29+
30+
version=$version ./yq -i '.version=strenv(version)' snap/snapcraft.yaml
31+
32+
actualSnapVersion=$(./yq '.version' snap/snapcraft.yaml)
33+
34+
if [ "$actualSnapVersion" != "$version" ]; then
35+
echo "Failed to update snapcraft"
36+
exit 1
37+
else
38+
echo "snapcraft updated"
39+
fi
40+
41+
git add cmd/version.go snap/snapcraft.yaml
42+
git commit -m 'Bumping version'
43+
git tag $version

scripts/xcompile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33
# you may need to go install github.com/mitchellh/[email protected] first
44
echo $VERSION
5-
CGO_ENABLED=0 gox -ldflags "${LDFLAGS} -X github.com/mikefarah/yq/v4/cmd.Version=${VERSION}" -output="build/yq_{{.OS}}_{{.Arch}}" --osarch="darwin/amd64 darwin/arm64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm linux/arm64 linux/mips linux/mips64 linux/mips64le linux/mipsle linux/ppc64 linux/ppc64le linux/s390x netbsd/386 netbsd/amd64 netbsd/arm openbsd/386 openbsd/amd64 windows/386 windows/amd64"
5+
CGO_ENABLED=0 gox -ldflags "${LDFLAGS}" -output="build/yq_{{.OS}}_{{.Arch}}" --osarch="darwin/amd64 darwin/arm64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm linux/arm64 linux/mips linux/mips64 linux/mips64le linux/mipsle linux/ppc64 linux/ppc64le linux/s390x netbsd/386 netbsd/amd64 netbsd/arm openbsd/386 openbsd/amd64 windows/386 windows/amd64"
66

77
cd build
88

snap/snapcraft.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
name: yq
2-
version: 'v4.30.3'
2+
version: 'v4.30.4'
33
summary: A lightweight and portable command-line YAML processor
44
description: |
55
The aim of the project is to be the jq or sed of yaml files.
6-
76
base: core18
87
grade: stable # devel|stable. must be 'stable' to release into candidate/stable channels
98
confinement: strict
10-
119
apps:
1210
yq:
1311
command: yq
1412
plugs: [home]
15-
1613
parts:
1714
yq:
1815
plugin: go

0 commit comments

Comments
 (0)