Compare commits

...

7 Commits

Author SHA1 Message Date
lukaszraczylo 7787fe5e6c Exclude md5 checks on binary. 2022-10-17 15:39:51 +01:00
lukaszraczylo be885367df Increase test coverage. 2022-10-17 15:30:21 +01:00
lukaszraczylo 3e885b5e7c Update checkout action to latest available.
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
2022-10-17 13:06:12 +01:00
lukaszraczylo 50282aa5f6 Fixup gomod and remove leftovers. 2022-10-17 13:04:02 +01:00
lukaszraczylo 5fa9728e0a Update dependencies to the latest available. 2022-10-17 13:00:38 +01:00
lukaszraczylo 084def2e9e Merge pull request #16 from lukaszraczylo/move-crossbuild
Change crossbuild to go-release-binaries.
2022-10-17 04:55:15 -07:00
lukaszraczylo 43b49666b6 Change crossbuild to go-release-binaries.
Reason: crossbuild action is deprecated and does not support current
latest versions of golang.
2022-10-17 12:49:07 +01:00
4 changed files with 145 additions and 59 deletions
+89 -52
View File
@@ -28,7 +28,7 @@ jobs:
RELEASE_VERSION: ${{ steps.get_env.outputs.RELEASE_VERSION }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Setting environment variables
@@ -37,6 +37,7 @@ jobs:
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/lukaszraczylo/semver-generator/releases/latest \
| grep browser_download_url \
| grep semver-gen-linux-amd64 \
| grep -v '.md5' \
| cut -d '"' -f 4)
curl -s -L -o semver-gen "$DOWNLOAD_URL" && chmod +x semver-gen
TMP_SANITISED_REPOSITORY_NAME=$(echo ${{ github.event.repository.name }} | sed -e 's|\.|-|g')
@@ -59,7 +60,7 @@ jobs:
CI: true
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Lint Code Base
if: env.ENABLE_CODE_LINT == true
env:
@@ -90,7 +91,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Configure git for private modules
run: |
make update
@@ -105,13 +106,33 @@ jobs:
with:
args: ./...
create-dummy-release:
needs: [ prepare, test, code_scans ]
name: Create empty release
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Get list of the commits since last release
run: |
echo "$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")" > .release_notes
- name: Create empty release
uses: ncipollo/release-action@v1
with:
bodyFile: ./.release_notes
name: version ${{ needs.prepare.outputs.RELEASE_VERSION }}
token: ${{ secrets.GHCR_TOKEN }}
tag: ${{ needs.prepare.outputs.RELEASE_VERSION }}
prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}
allowUpdates: true
build:
needs: [ prepare, test, code_scans ]
name: Docker image build (regular:multiarch)
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
@@ -165,60 +186,76 @@ jobs:
# fail-build: false
build-binary:
needs: [ prepare, test, code_scans ]
needs: [ prepare, test, code_scans, create-dummy-release ]
name: Binary compilation and release
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm64]
exclude:
- goarch: "386"
goos: darwin
- goarch: arm64
goos: windows
continue-on-error: [true]
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Compile binary
uses: thatisuday/go-cross-build@v1.1.0
uses: wangyoucao577/go-release-action@v1.32
with:
platforms: linux/amd64,darwin/amd64,windows/amd64,linux/arm64,darwin/amd64,darwin/arm64
name: semver-gen
package: ./
compress: false
dest: dist
github_token: ${{ secrets.GHCR_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
ldflags: -s -w -X main.PKG_VERSION=${{ needs.prepare.outputs.RELEASE_VERSION }}
- name: Get list of the commits since last release
run: |
echo "$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")" > .release_notes
- name: Create Release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
files: dist/semver-gen-*
automatic_release_tag: ${{ needs.prepare.outputs.RELEASE_VERSION }}
title: version ${{ needs.prepare.outputs.RELEASE_VERSION }}
# tag: ${{ needs.prepare.outputs.RELEASE_VERSION }}
# name: ${{ needs.prepare.outputs.RELEASE_VERSION }}
# body_path: .release_notes
# draft: false
prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}
- name: Delete previous v1 release asset
uses: mknejp/delete-release-assets@v1
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
with:
token: ${{ github.token }}
fail-if-no-assets: false
fail-if-no-release: false
tag: v1
assets: 'semver-gen-*'
- name: Create Release V1
id: create_release_global
uses: marvinpinto/action-automatic-releases@latest
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
files: dist/semver-gen-*
automatic_release_tag: v1
title: version v1:${{ needs.prepare.outputs.RELEASE_VERSION }}
prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}
project_path: .
binary_name: semver-gen
asset_name: semver-gen-${{ matrix.goos }}-${{ matrix.goarch }}
release_name: version ${{ needs.prepare.outputs.RELEASE_VERSION }}
release_tag: ${{ needs.prepare.outputs.RELEASE_VERSION }}
compress_assets: false
retry: 10
overwrite: true
pre_command: export GODEBUG=http2client=0
# - name: Create Release
# id: create_release
# uses: marvinpinto/action-automatic-releases@latest
# if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# files: dist/semver-gen-*
# automatic_release_tag: ${{ needs.prepare.outputs.RELEASE_VERSION }}
# title: version ${{ needs.prepare.outputs.RELEASE_VERSION }}
# # tag: ${{ needs.prepare.outputs.RELEASE_VERSION }}
# # name: ${{ needs.prepare.outputs.RELEASE_VERSION }}
# # body_path: .release_notes
# # draft: false
# prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}
# - name: Delete previous v1 release asset
# uses: mknejp/delete-release-assets@v1
# if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
# with:
# token: ${{ github.token }}
# fail-if-no-assets: false
# fail-if-no-release: false
# tag: v1
# assets: 'semver-gen-*'
# - name: Create Release V1
# id: create_release_global
# uses: marvinpinto/action-automatic-releases@latest
# if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# files: dist/semver-gen-*
# automatic_release_tag: v1
# title: version v1:${{ needs.prepare.outputs.RELEASE_VERSION }}
# prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}
+50 -1
View File
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -581,3 +581,52 @@ func (suite *Tests) Test_parseExistingSemver() {
})
}
}
func (suite *Tests) TestSetup_ListExistingTags() {
type fields struct {
RepositoryName string
RepositoryLocalPath string
RepositoryHandler *git.Repository
LocalConfigFile string
Commits []CommitDetails
Semver SemVer
Wording Wording
Force Force
}
tests := []struct {
name string
fields fields
noTags bool
}{
{
name: "List tags from existing repository",
fields: fields{
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
},
noTags: false,
},
{
name: "List tags from non-existing repository",
fields: fields{
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client-dead",
},
noTags: true,
},
}
for _, tt := range tests {
suite.T().Run(tt.name, func(t *testing.T) {
s := &Setup{}
s.ReadConfig(tt.fields.LocalConfigFile)
s.RepositoryName = tt.fields.RepositoryName
s.Force = tt.fields.Force
s.Prepare()
s.ListExistingTags()
if tt.noTags {
assert.Equal(len(s.Tags), 0, "Unexpected number of tags in "+tt.name)
} else {
assert.GreaterOrEqual(len(s.Tags), 1, "Unexpected number of tags in "+tt.name)
}
})
}
}
+2 -2
View File
@@ -8,7 +8,7 @@ require (
github.com/lukaszraczylo/go-simple-graphql v1.0.61
github.com/lukaszraczylo/pandati v0.0.15
github.com/melbahja/got v0.7.0
github.com/spf13/cobra v1.5.0
github.com/spf13/cobra v1.6.0
github.com/spf13/viper v1.13.0
github.com/stretchr/testify v1.8.0
github.com/tidwall/gjson v1.14.3
@@ -26,7 +26,7 @@ require (
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
+4 -4
View File
@@ -158,8 +158,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
@@ -231,8 +231,8 @@ github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo=
github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI=
github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=