Skip to content

Commit

Permalink
Fixing versioning code for release
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed Nov 15, 2022
1 parent fd35530 commit a6d1a52
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 19 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jobs:
mkdir -p build
cp yq.1 build/yq.1
./scripts/xcompile.sh
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
- name: Release
uses: softprops/action-gh-release@v1
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/snap-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF##*/}" >> "${GITHUB_OUTPUT}"

- name: Update snapcraft version file
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
uses: mikefarah/yq@master
with:
cmd: yq -i '.version = strenv(VERSION)' snap/snapcraft.yaml
- uses: snapcore/action-build@v1
id: build
- uses: snapcore/action-publish@v1
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var (
GitDescribe string

// Version is main version number that is being run at the moment.
Version = ""
Version = "v4.30.4"

// VersionPrerelease is a pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
Expand Down
43 changes: 43 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e

if [ "$1" == "" ]; then
echo "Please specify at a version"
exit 1
fi

version=$1

# validate version is in the right format
echo $version | sed -r '/v4\.[0-9][0-9]\.[0-9][0-9]?$/!{q1}'

previousVersion=$(cat cmd/version.go| sed -n 's/.*Version = "\([^"]*\)"/\1/p')

echo "Updating from $previousVersion to $version"

sed -i "s/\(.*Version =\).*/\1 \"$version\"/" cmd/version.go

go build .
actualVersion=$(./yq --version)

if [ "$actualVersion" != "yq (https://github.com/mikefarah/yq/) version $version" ]; then
echo "Failed to update version.go"
exit 1
else
echo "version.go updated"
fi

version=$version ./yq -i '.version=strenv(version)' snap/snapcraft.yaml

actualSnapVersion=$(./yq '.version' snap/snapcraft.yaml)

if [ "$actualSnapVersion" != "$version" ]; then
echo "Failed to update snapcraft"
exit 1
else
echo "snapcraft updated"
fi

git add cmd/version.go snap/snapcraft.yaml
git commit -m 'Bumping version'
git tag $version
2 changes: 1 addition & 1 deletion scripts/xcompile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e
# you may need to go install github.com/mitchellh/[email protected] first
echo $VERSION
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"
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"

cd build

Expand Down
5 changes: 1 addition & 4 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
name: yq
version: 'v4.30.3'
version: 'v4.30.4'
summary: A lightweight and portable command-line YAML processor
description: |
The aim of the project is to be the jq or sed of yaml files.
base: core18
grade: stable # devel|stable. must be 'stable' to release into candidate/stable channels
confinement: strict

apps:
yq:
command: yq
plugs: [home]

parts:
yq:
plugin: go
Expand Down

0 comments on commit a6d1a52

Please sign in to comment.