mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-25 21:51:38 +00:00
Merge pull request #46 from yggdrasil-network/semver
Use semantic versioning (fixes #45)
This commit is contained in:
commit
c1fe7d271e
@ -15,48 +15,47 @@ jobs:
|
|||||||
name: Create artifact upload directory and set variables
|
name: Create artifact upload directory and set variables
|
||||||
command: |
|
command: |
|
||||||
mkdir /tmp/upload
|
mkdir /tmp/upload
|
||||||
echo 'export CIBUILD=$(cat VERSION).$(git rev-list HEAD --count | xargs printf "%04d")' >> $BASH_ENV
|
echo 'export CINAME=$(sh contrib/semver/name.sh)' >> $BASH_ENV
|
||||||
echo 'export CIBRANCH=$(git name-rev --name-only HEAD)' >> $BASH_ENV
|
echo 'export CIVERSION=$(sh contrib/semver/version.sh | cut -c 2-)' >> $BASH_ENV
|
||||||
echo '[ "$CIBRANCH" != "master" ] && export CIVERSION=$CIBRANCH-$CIBUILD || export CIVERSION=$CIBUILD' >> $BASH_ENV
|
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Build for Linux (including Debian packages)
|
name: Build for Linux (including Debian packages)
|
||||||
command: |
|
command: |
|
||||||
PKGARCH=amd64 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-linux-amd64;
|
PKGARCH=amd64 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-amd64;
|
||||||
PKGARCH=i386 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-linux-i386;
|
PKGARCH=i386 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-i386;
|
||||||
PKGARCH=mipsel sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-linux-mipsel;
|
PKGARCH=mipsel sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-mipsel;
|
||||||
PKGARCH=mips sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-linux-mips;
|
PKGARCH=mips sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-mips;
|
||||||
mv *.deb /tmp/upload/
|
mv *.deb /tmp/upload/
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Build for macOS
|
name: Build for macOS
|
||||||
command: |
|
command: |
|
||||||
GOOS=darwin GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-darwin-amd64;
|
GOOS=darwin GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-darwin-amd64;
|
||||||
GOOS=darwin GOARCH=386 ./build && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-darwin-i386;
|
GOOS=darwin GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-darwin-i386;
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Build for OpenBSD
|
name: Build for OpenBSD
|
||||||
command: |
|
command: |
|
||||||
GOOS=openbsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-openbsd-amd64;
|
GOOS=openbsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-openbsd-amd64;
|
||||||
GOOS=openbsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-openbsd-i386;
|
GOOS=openbsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-openbsd-i386;
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Build for FreeBSD
|
name: Build for FreeBSD
|
||||||
command: |
|
command: |
|
||||||
GOOS=freebsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-freebsd-amd64;
|
GOOS=freebsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-amd64;
|
||||||
GOOS=freebsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-freebsd-i386;
|
GOOS=freebsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-i386;
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Build for NetBSD
|
name: Build for NetBSD
|
||||||
command: |
|
command: |
|
||||||
GOOS=netbsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-netbsd-amd64;
|
GOOS=netbsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-netbsd-amd64;
|
||||||
GOOS=netbsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/yggdrasil-$CIVERSION-netbsd-i386;
|
GOOS=netbsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-netbsd-i386;
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Build for Windows
|
name: Build for Windows
|
||||||
command: |
|
command: |
|
||||||
GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe /tmp/upload/yggdrasil-$CIVERSION-windows-amd64.exe;
|
GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-amd64.exe;
|
||||||
GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe /tmp/upload/yggdrasil-$CIVERSION-windows-i386.exe;
|
GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-i386.exe;
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Build for EdgeRouter
|
name: Build for EdgeRouter
|
||||||
|
@ -11,10 +11,9 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PKGBRANCH=$(basename `git name-rev --name-only HEAD`)
|
PKGBRANCH=$(basename `git name-rev --name-only HEAD`)
|
||||||
if [ "$PKGBRANCH" = "master" ]; then PKGNAME=yggdrasil
|
PKGNAME=$(sh contrib/semver/name.sh)
|
||||||
else PKGNAME=yggdrasil-${PKGBRANCH}; fi
|
PKGVERSION=$(sh contrib/semver/version.sh | cut -c 2-)
|
||||||
PKGARCH=${PKGARCH-amd64}
|
PKGARCH=${PKGARCH-amd64}
|
||||||
PKGVERSION=$(cat VERSION).$(git rev-list HEAD --count 2>/dev/null | xargs printf "%04d")
|
|
||||||
PKGFILE=$PKGNAME-$PKGVERSION-$PKGARCH.deb
|
PKGFILE=$PKGNAME-$PKGVERSION-$PKGARCH.deb
|
||||||
|
|
||||||
if [ $PKGARCH = "amd64" ]; then GOARCH=amd64 GOOS=linux ./build
|
if [ $PKGARCH = "amd64" ]; then GOARCH=amd64 GOOS=linux ./build
|
||||||
|
13
contrib/semver/name.sh
Normal file
13
contrib/semver/name.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Get the branch name
|
||||||
|
BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null)
|
||||||
|
|
||||||
|
# Check if the branch name is not master
|
||||||
|
if [ "$BRANCH" = "master" ]; then
|
||||||
|
printf "yggdrasil"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If it is something other than master, append it
|
||||||
|
printf "yggdrasil-%s" "$BRANCH"
|
26
contrib/semver/version.sh
Normal file
26
contrib/semver/version.sh
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Get the last tag
|
||||||
|
TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*" 2>/dev/null)
|
||||||
|
|
||||||
|
# Get the number of commits from the last tag
|
||||||
|
COUNT=$(git rev-list $TAG..HEAD --count 2>/dev/null)
|
||||||
|
|
||||||
|
# If it fails then there's no last tag - go from the first commit
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
COUNT=$(git rev-list HEAD --count 2>/dev/null)
|
||||||
|
|
||||||
|
printf 'v0.0.%d' "$COUNT"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split out into major, minor and patch numbers
|
||||||
|
MAJOR=$(echo $TAG | cut -c 2- | cut -d "." -f 1)
|
||||||
|
MINOR=$(echo $TAG | cut -c 2- | cut -d "." -f 2)
|
||||||
|
|
||||||
|
# Output in the desired format
|
||||||
|
if [ $COUNT = 0 ]; then
|
||||||
|
printf 'v%d.%d' "$MAJOR" "$MINOR"
|
||||||
|
else
|
||||||
|
printf 'v%d.%d.%d' "$MAJOR" "$MINOR" "$COUNT"
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user