mirror of
https://github.com/lukaszraczylo/semver-generator.git
synced 2026-06-16 01:31:19 +00:00
Compare commits
200 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cdeb4343f7 | |||
| 4116b946dd | |||
| 2771fb826b | |||
| aa49ffa1b0 | |||
| fedb4a8a91 | |||
| 526da00875 | |||
| 7e8f08a8b3 | |||
| 796f250a1a | |||
| 4af6684c3a | |||
| b726c86f84 | |||
| 22bcef3554 | |||
| e15d8a41ff | |||
| 4aa86e7a5f | |||
| cef4671c72 | |||
| e470133f20 | |||
| 8aa834fc2d | |||
| 3b89f395bc | |||
| df08132c03 | |||
| 0125909c42 | |||
| 0d0372c9fa | |||
| 4314c99412 | |||
| de8b24b2ea | |||
| a5b1c83b90 | |||
| efe0f8d141 | |||
| d28f243e36 | |||
| f5167e88b2 | |||
| f6316cad03 | |||
| fdca151989 | |||
| fa4425d296 | |||
| a3907e304d | |||
| ddfdbbf6b4 | |||
| efeb0c4633 | |||
| 22422cbf1c | |||
| d5446fd3a2 | |||
| 5ceddb754c | |||
| 76e50d0512 | |||
| d49007ffc8 | |||
| 53b59424bb | |||
| 1317ad074a | |||
| 185430d76d | |||
| 06e8db4fa7 | |||
| 603397cf7f | |||
| 966388c406 | |||
| 114d1b3788 | |||
| e5af931d29 | |||
| d37cc5b41f | |||
| b7ac18840f | |||
| f0685cc4db | |||
| d7f5610110 | |||
| ce31233c55 | |||
| 2d997993ec | |||
| a5b861ee36 | |||
| 8771fe5a0b | |||
| 2f33609171 | |||
| 8a4f34ba1e | |||
| 3ce355f9c2 | |||
| e3a8b37d56 | |||
| 4cda329513 | |||
| 1672a9c3fe | |||
| 99a2236c36 | |||
| 57b0a013d7 | |||
| eedc099648 | |||
| dbf46f11f3 | |||
| 5f21d71b50 | |||
| b0f448b810 | |||
| 3c61b6d709 | |||
| 481f916b51 | |||
| 888525e4d2 | |||
| c789560b31 | |||
| f568197a00 | |||
| e6bb79646b | |||
| 26d0c3bcd6 | |||
| f6da1de36f | |||
| 4aae40ef34 | |||
| 66538c4bdb | |||
| df95d6a0e2 | |||
| f6ee659f39 | |||
| 376e857d3e | |||
| f6938c7a32 | |||
| dcd8bb922f | |||
| f6196743e8 | |||
| 8a34562f19 | |||
| c8dba1132e | |||
| d4b99cb84e | |||
| f00399804b | |||
| 08fff358b4 | |||
| b64578ba8a | |||
| acc310880d | |||
| 27e7d40c0a | |||
| 079fd59952 | |||
| 5c0d2109b0 | |||
| 3d89a11084 | |||
| 5ad41dc08b | |||
| 721453e383 | |||
| 81b813d136 | |||
| b15fac4856 | |||
| cfd933f283 | |||
| af3572a9df | |||
| df00bc19bc | |||
| 82a520b858 | |||
| d1987d08bc | |||
| eb513ca5f9 | |||
| f51cb018cf | |||
| 3d75e166af | |||
| 6c1281a87b | |||
| e709f61317 | |||
| c49e94b36a | |||
| dead601864 | |||
| eea0b9031d | |||
| c8759d43e9 | |||
| 343496c6c3 | |||
| 129acb3cfe | |||
|
ca3d1b6da0
|
|||
| 3c96bdd3c2 | |||
|
b999885e0e
|
|||
|
5e945c4ba0
|
|||
|
e8742c29b5
|
|||
|
e168e99151
|
|||
|
e54b3d339b
|
|||
|
403b3f115f
|
|||
|
76fdbd6f50
|
|||
| 67d110295f | |||
| 5c63edcc2e | |||
|
1bf33c3a65
|
|||
| 3859fe0469 | |||
| ac953ab411 | |||
|
9e333c7a45
|
|||
|
80e669e5b5
|
|||
|
fd32148a53
|
|||
|
0fa3b15a5c
|
|||
|
6a34323712
|
|||
|
eeba71c954
|
|||
|
a73dd78bd5
|
|||
|
817fb91dba
|
|||
| 601f486b60 | |||
| 5203ba9f8b | |||
|
9e54d213a7
|
|||
|
acdc87db7d
|
|||
|
5aaaf3c599
|
|||
|
de8d0dba1d
|
|||
|
b51ea576a3
|
|||
|
a1c81c7120
|
|||
|
2f78fd46ef
|
|||
|
ecd0363c45
|
|||
|
2405a93eb2
|
|||
|
c97f47c48b
|
|||
|
8217ece82d
|
|||
|
c601de437d
|
|||
|
c03086e36c
|
|||
|
b20a9f8eb7
|
|||
|
19fd1d8d3e
|
|||
|
37a6482e74
|
|||
|
9c1e1f2217
|
|||
|
746defdaa2
|
|||
|
fc44b5644c
|
|||
|
1cba7edb6a
|
|||
|
e04690acdb
|
|||
|
a517359fec
|
|||
| 6057b7502d | |||
| 95d80e71cc | |||
|
96228eaac7
|
|||
|
ea75bd4816
|
|||
|
36e0617b29
|
|||
|
957f17f0a5
|
|||
|
e9e05973a4
|
|||
|
04d31b5e78
|
|||
|
7fa90bf397
|
|||
|
491bb087ab
|
|||
|
f81072b1fe
|
|||
|
d3f6b007a3
|
|||
|
b786463ed6
|
|||
|
901f16a331
|
|||
|
7bb6a0d0f6
|
|||
|
c08aeae7f1
|
|||
|
915c9a9f71
|
|||
|
7787fe5e6c
|
|||
|
be885367df
|
|||
|
3e885b5e7c
|
|||
|
50282aa5f6
|
|||
|
5fa9728e0a
|
|||
| 084def2e9e | |||
|
43b49666b6
|
|||
|
a89c69dda8
|
|||
|
33ec1c7ce4
|
|||
|
abb1152ec7
|
|||
|
1bcccf227e
|
|||
|
9c355d1267
|
|||
|
821454583e
|
|||
|
ba588a0c6f
|
|||
|
47546fca4f
|
|||
|
8a6b6d48e6
|
|||
|
fefb87c3d4
|
|||
|
a5642b30e6
|
|||
|
9b03bb1566
|
|||
|
551e1b9d21
|
|||
|
58151695a3
|
|||
|
77616d4cdb
|
|||
|
4451f4b9b5
|
|||
| 74b11f30c9 | |||
|
3a33815ea0
|
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug, to be confirmed
|
||||
assignees: lukaszraczylo
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Output with debug**
|
||||
[ paste output of the command with `-d` flag here ]
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "gomod" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -0,0 +1,74 @@
|
||||
name: Autoupdate go.mod and go.sum
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 3 * * *"
|
||||
|
||||
env:
|
||||
GO_VERSION: ">=1.21"
|
||||
|
||||
jobs:
|
||||
# This job is responsible for preparation of the build
|
||||
# environment variables.
|
||||
prepare:
|
||||
name: Preparing build context
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v5
|
||||
id: cache
|
||||
with:
|
||||
go-version: ${{env.GO_VERSION}}
|
||||
cache-dependency-path: "**/*.sum"
|
||||
|
||||
- name: Go get dependencies
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
go get ./...
|
||||
|
||||
# This job is responsible for running tests and linting the codebase
|
||||
test:
|
||||
name: "Unit testing"
|
||||
runs-on: ubuntu-latest
|
||||
container: golang:1
|
||||
needs: [prepare]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Ensure full history is checked out
|
||||
token: ${{ secrets.GHCR_TOKEN }}
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{env.GO_VERSION}}
|
||||
cache-dependency-path: "**/*.sum"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install ca-certificates make -y
|
||||
update-ca-certificates
|
||||
go mod tidy
|
||||
go get -u -v ./...
|
||||
go mod tidy -v
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
export GITHUB_TOKEN=${{ secrets.GHCR_TOKEN }}
|
||||
CI_RUN=${CI} make test
|
||||
git config --global --add safe.directory /__w/semver-generator/semver-generator
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "Update go.mod and go.sum"
|
||||
commit_options: "--no-verify --signoff"
|
||||
file_pattern: "go.mod go.sum"
|
||||
@@ -6,6 +6,7 @@ on:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '**/release.yaml'
|
||||
- 'action.yml'
|
||||
branches:
|
||||
- "master"
|
||||
- "main"
|
||||
@@ -14,6 +15,7 @@ env:
|
||||
ENABLE_CODE_LINT: false
|
||||
ENABLE_CODE_SCANS: false
|
||||
DEPLOY: false
|
||||
GO_VERSION: 1.21
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
@@ -28,27 +30,29 @@ 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
|
||||
id: get_env
|
||||
run: |
|
||||
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/lukaszraczylo/semver-generator/releases/latest \
|
||||
| grep browser_download_url \
|
||||
| grep semver-gen-linux-amd64 \
|
||||
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/lukaszraczylo/semver-generator/releases/latest | grep -E ".*browser_download_url.*linux-" | grep -vE "(arm64|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')
|
||||
TMP_GITHUB_COMMITS_COUNT=$(git rev-list --count HEAD)
|
||||
TMP_GITHUB_COUNT_NUMBER=$(echo ${GITHUB_RUN_NUMBER})
|
||||
TMP_RELEASE_VERSION=$(./semver-gen generate -l -c config-release.yaml | sed -e 's|SEMVER ||g')
|
||||
echo "::set-output name=SANITISED_REPOSITORY_NAME::$TMP_SANITISED_REPOSITORY_NAME"
|
||||
echo "::set-output name=DOCKER_IMAGE::ghcr.io/${{ github.repository_owner }}/$TMP_SANITISED_REPOSITORY_NAME"
|
||||
echo "::set-output name=GITHUB_COMMIT_NUMBER::$TMP_GITHUB_COMMITS_COUNT"
|
||||
echo "::set-output name=GITHUB_SHA::$(echo ${GITHUB_SHA::8})"
|
||||
echo "::set-output name=GITHUB_RUN_ID::$TMP_GITHUB_COUNT_NUMBER"
|
||||
echo "::set-output name=RELEASE_VERSION::$TMP_RELEASE_VERSION"
|
||||
|
||||
echo ">> Release version: $TMP_RELEASE_VERSION <<"
|
||||
|
||||
# Setting outputs
|
||||
echo "SANITISED_REPOSITORY_NAME=$TMP_SANITISED_REPOSITORY_NAME" > $GITHUB_OUTPUT
|
||||
echo "DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/$TMP_SANITISED_REPOSITORY_NAME" >> $GITHUB_OUTPUT
|
||||
echo "GITHUB_COMMIT_NUMBER=$TMP_GITHUB_COMMITS_COUNT" >> $GITHUB_OUTPUT
|
||||
echo "GITHUB_SHA=$(echo ${GITHUB_SHA::8})" >> $GITHUB_OUTPUT
|
||||
echo "GITHUB_RUN_ID=$TMP_GITHUB_COUNT_NUMBER" >> $GITHUB_OUTPUT
|
||||
echo "RELEASE_VERSION=$TMP_RELEASE_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
test:
|
||||
needs: [ prepare ]
|
||||
@@ -59,7 +63,11 @@ jobs:
|
||||
CI: true
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Lint Code Base
|
||||
if: env.ENABLE_CODE_LINT == true
|
||||
env:
|
||||
@@ -78,11 +86,12 @@ jobs:
|
||||
run: |
|
||||
make test CI_RUN=${CI}
|
||||
- name: Upload codecov result
|
||||
uses: codecov/codecov-action@v1
|
||||
uses: codecov/codecov-action@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
|
||||
files: coverage.out
|
||||
fail_ci_if_error: false
|
||||
|
||||
code_scans:
|
||||
needs: [ prepare ]
|
||||
@@ -90,7 +99,11 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Configure git for private modules
|
||||
run: |
|
||||
make update
|
||||
@@ -105,20 +118,70 @@ jobs:
|
||||
with:
|
||||
args: ./...
|
||||
|
||||
build:
|
||||
|
||||
build-binary:
|
||||
needs: [ prepare, test, code_scans ]
|
||||
name: Docker image build (regular:multiarch)
|
||||
name: Binary compilation and release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Build binaries
|
||||
run: |
|
||||
LOCAL_VERSION=${{ needs.prepare.outputs.RELEASE_VERSION }} make dist-release
|
||||
|
||||
- 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 [semver]
|
||||
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' }}
|
||||
artifacts: "dist/*"
|
||||
allowUpdates: true
|
||||
|
||||
- name: Delete existing v1 tag and release
|
||||
run: |
|
||||
gh release delete v1 --cleanup-tag -y
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GHCR_TOKEN }}
|
||||
|
||||
- name: Create release [v1]
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
bodyFile: ./.release_notes
|
||||
name: v1 - ${{ needs.prepare.outputs.RELEASE_VERSION }}
|
||||
token: ${{ secrets.GHCR_TOKEN }}
|
||||
tag: v1
|
||||
prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}
|
||||
artifacts: "dist/*"
|
||||
allowUpdates: true
|
||||
makeLatest: false
|
||||
|
||||
build-docker:
|
||||
needs: [ prepare, test, code_scans, build-binary ]
|
||||
name: Docker image build
|
||||
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
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to GHCR
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.ACTOR }}
|
||||
@@ -127,23 +190,23 @@ jobs:
|
||||
id: prep
|
||||
run: |
|
||||
if [ -z "${{ needs.prepare.outputs.RELEASE_VERSION }}" ]; then
|
||||
TAGS="${{ needs.prepare.outputs.DOCKER_IMAGE }}:${{ needs.prepare.outputs.GITHUB_SHA }},${{ needs.prepare.outputs.DOCKER_IMAGE }}:latest"
|
||||
TAGS="${{ needs.prepare.outputs.DOCKER_IMAGE }}:${{ needs.prepare.outputs.GITHUB_SHA }},${{ needs.prepare.outputs.DOCKER_IMAGE }}:latest,${{ needs.prepare.outputs.DOCKER_IMAGE }}:v1"
|
||||
else
|
||||
TAGS="${{ needs.prepare.outputs.DOCKER_IMAGE }}:${{ needs.prepare.outputs.GITHUB_SHA }},${{ needs.prepare.outputs.DOCKER_IMAGE }}:${{ needs.prepare.outputs.RELEASE_VERSION }},${{ needs.prepare.outputs.DOCKER_IMAGE }}:latest"
|
||||
TAGS="${{ needs.prepare.outputs.DOCKER_IMAGE }}:${{ needs.prepare.outputs.GITHUB_SHA }},${{ needs.prepare.outputs.DOCKER_IMAGE }}:${{ needs.prepare.outputs.RELEASE_VERSION }},${{ needs.prepare.outputs.DOCKER_IMAGE }}:latest,${{ needs.prepare.outputs.DOCKER_IMAGE }}:v1"
|
||||
fi
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
|
||||
BRANCH=$(echo ${GITHUB_REF##*/} | tr '[A-Z]' '[a-z]')
|
||||
LABELS="org.opencontainers.image.revision=${{ needs.prepare.outputs.GITHUB_SHA }}"
|
||||
LABELS="$LABELS,org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
LABELS="$LABELS,org.opencontainers.image.version=$VERSION"
|
||||
LABELS="$LABELS,com.github.repo.branch=$BRANCH"
|
||||
LABELS="$LABELS,com.github.repo.dockerfile=Dockerfile"
|
||||
echo ::set-output name=labels::${LABELS}
|
||||
echo "LABELS=$LABELS" >> $GITHUB_OUTPUT
|
||||
BUILD_ARGS="BRANCH=$BRANCH"
|
||||
echo ::set-output name=args::${BUILD_ARGS}
|
||||
echo "args=$BUILD_ARGS" >> $GITHUB_OUTPUT
|
||||
- name: Build image
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
platforms: linux/arm64,linux/amd64
|
||||
@@ -157,67 +220,3 @@ jobs:
|
||||
${{ steps.prep.outputs.args }}
|
||||
labels: ${{ steps.prep.outputs.labels }}
|
||||
no-cache: false
|
||||
- name: Scan image
|
||||
uses: anchore/scan-action@v2
|
||||
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
|
||||
with:
|
||||
image: "${{ needs.prepare.outputs.DOCKER_IMAGE }}:${{ needs.prepare.outputs.GITHUB_SHA }}"
|
||||
fail-build: true
|
||||
|
||||
build-binary:
|
||||
needs: [ prepare, test, code_scans ]
|
||||
name: Binary compilation and release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Compile binary
|
||||
uses: thatisuday/go-cross-build@v1.0.2
|
||||
with:
|
||||
platforms: linux/amd64,darwin/amd64,windows/amd64,linux/arm64,darwin/amd64,darwin/arm64
|
||||
name: semver-gen
|
||||
package: ./
|
||||
compress: false
|
||||
dest: dist
|
||||
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
|
||||
# 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' }}
|
||||
|
||||
+3
-1
@@ -1,2 +1,4 @@
|
||||
semver-gen
|
||||
coverage.out
|
||||
coverage.out
|
||||
.vscode
|
||||
.DS_Store
|
||||
+5
-12
@@ -1,17 +1,10 @@
|
||||
# syntax=docker/dockerfile:1.2.1-labs
|
||||
|
||||
FROM golang:1-alpine as baseimg
|
||||
|
||||
RUN apk add make
|
||||
FROM golang:1-bullseye as baseimg
|
||||
WORKDIR /go/src/app
|
||||
ENV GO111MODULE=on CGO_ENABLED=1 GOOS=linux
|
||||
COPY . /go/src/app/
|
||||
RUN make
|
||||
RUN CGO_ENABLED=1 make build
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk add --no-cache ca-certificates
|
||||
WORKDIR /go/src/app
|
||||
COPY --from=baseimg /go/src/app/semver-gen .
|
||||
COPY --from=baseimg /go/src/app/config-release.yaml config.yaml
|
||||
FROM ubuntu:jammy
|
||||
COPY --from=baseimg /go/src/app/semver-gen /go/src/app/semver-gen
|
||||
COPY --from=baseimg /go/src/app/config-release.yaml /go/src/app/config.yaml
|
||||
COPY --from=baseimg /go/src/app/entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -1,21 +1,51 @@
|
||||
LOCAL_VERSION?=$(shell semver-gen generate -l -c config-release.yaml | sed -e 's|SEMVER ||g')
|
||||
LOCAL_VERSION?=""
|
||||
CI_RUN?=false
|
||||
ADDITIONAL_BUILD_FLAGS=""
|
||||
LDFLAGS=-s -w -X main.PKG_VERSION=${LOCAL_VERSION}
|
||||
|
||||
ifeq ($(CI_RUN), true)
|
||||
ADDITIONAL_BUILD_FLAGS="-test.short"
|
||||
endif
|
||||
|
||||
all: build
|
||||
ifneq ($(shell which semver-gen), "")
|
||||
LOCAL_VERSION="0.0.0-dev"
|
||||
else
|
||||
LOCAL_VERSION=$(shell semver-gen generate -l -c config-release.yaml | sed -e 's|SEMVER ||g')
|
||||
endif
|
||||
|
||||
build:
|
||||
.PHONY: help
|
||||
help: ## display this help
|
||||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
|
||||
|
||||
.PHONY: all
|
||||
all: build ## Build all targets
|
||||
|
||||
.PHONY: build
|
||||
build: ## Build binary
|
||||
go build -o semver-gen -ldflags="-s -w -X main.PKG_VERSION=${LOCAL_VERSION}" *.go
|
||||
|
||||
run: build
|
||||
@./semver-gen
|
||||
# .PHONY: run
|
||||
# run: build ## Build binary and execute it
|
||||
# @./semver-gen
|
||||
|
||||
test:
|
||||
.PHONY: test
|
||||
test: ## Run whole test suite
|
||||
@go test ./... $(ADDITIONAL_BUILD_FLAGS) -v -race -cover -coverprofile=coverage.out
|
||||
|
||||
update:
|
||||
.PHONY: update
|
||||
update: ## Update dependencies
|
||||
@go get -u ./...
|
||||
@go mod tidy
|
||||
|
||||
.PHONY: update-all
|
||||
update-all: ## Update all dependencies and sub-packages
|
||||
@go get -u ./...
|
||||
|
||||
dist-release: ## Build all binaries
|
||||
rm -fr dist/ || true
|
||||
mkdir -p dist/
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -a -installsuffix cgo -o dist/semver-gen-linux-amd64
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -a -installsuffix cgo -o dist/semver-gen-linux-arm64
|
||||
CGO_ENABLED=0 GOOS=darwin go build -ldflags="$(LDFLAGS)" -a -installsuffix cgo -o dist/semver-gen-darwin-amd64
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -a -installsuffix cgo -o dist/semver-gen-darwin-arm64
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -a -installsuffix cgo -o dist/semver-gen-windows-amd64.exe
|
||||
@@ -13,8 +13,8 @@ Project created overnight, to prove that management of semantic versioning is NO
|
||||
- [As a binary](#as-a-binary)
|
||||
- [As a github action](#as-a-github-action)
|
||||
- [As a docker container](#as-a-docker-container)
|
||||
- [Calculations example [standard]](#calculations-example-standard)
|
||||
- [Calculations example [strict matching]](#calculations-example-strict-matching)
|
||||
- [Calculations example \[standard\]](#calculations-example-standard)
|
||||
- [Calculations example \[strict matching\]](#calculations-example-strict-matching)
|
||||
- [Release candidates](#release-candidates)
|
||||
- [Example configuration](#example-configuration)
|
||||
- [Good to know](#good-to-know)
|
||||
@@ -78,6 +78,7 @@ Flags:
|
||||
-h, --help help for semver-gen
|
||||
-l, --local Use local repository
|
||||
-r, --repository string Remote repository URL. (default "https://github.com/lukaszraczylo/simple-gql-client")
|
||||
-b, --branch string Remote repository URL Branch. (default "main")
|
||||
-s, --strict Strict matching
|
||||
-u, --update Update binary with latest
|
||||
-v, --version Display version
|
||||
@@ -111,6 +112,8 @@ jobs:
|
||||
# when using remote repository, especially with private one:
|
||||
github_username: lukaszraczylo
|
||||
github_token: MySupeRSecr3tPa$$w0rd
|
||||
strict: true
|
||||
existing: false
|
||||
- name: Semver check
|
||||
run: |
|
||||
echo "Semantic version detected: ${{ steps.semver.outputs.semantic_version }}"
|
||||
@@ -192,4 +195,5 @@ wording:
|
||||
### Good to know
|
||||
|
||||
* Word matching uses fuzzy search AND is case INSENSITIVE
|
||||
* I do not recommend using common words ( like "the" from the example configuration )
|
||||
* I do not recommend using common words ( like "the" from the example configuration )
|
||||
* You can specify env variable `LOG_LEVEL=debug` to see what exactly happens during the calculations
|
||||
+20
-11
@@ -1,30 +1,39 @@
|
||||
# action.yml
|
||||
name: 'Semantic Version Generator'
|
||||
description: 'Automagic semantic version generator'
|
||||
name: "Semantic Version Generator"
|
||||
description: "Automagic semantic version generator"
|
||||
author: Lukasz Raczylo
|
||||
branding:
|
||||
icon: chevron-right
|
||||
color: gray-dark
|
||||
inputs:
|
||||
config_file:
|
||||
description: 'Configuration file'
|
||||
description: "Configuration file"
|
||||
required: false
|
||||
repository_url:
|
||||
description: 'Repository URL'
|
||||
description: "Repository URL"
|
||||
required: false
|
||||
default: 'https://github.com/lukaszraczylo/simple-gql-client'
|
||||
default: "https://github.com/lukaszraczylo/simple-gql-client"
|
||||
repository_local:
|
||||
description: 'Use already cloned repository in current directory'
|
||||
description: "Use already cloned repository in current directory"
|
||||
required: false
|
||||
github_token:
|
||||
description: 'GitHub Personal Access Token OR password'
|
||||
description: "GitHub Personal Access Token OR password"
|
||||
required: false
|
||||
github_username:
|
||||
description: 'GitHub or other git hosting provider username'
|
||||
description: "GitHub or other git hosting provider username"
|
||||
required: false
|
||||
strict:
|
||||
description: "Strict mode"
|
||||
required: false
|
||||
existing:
|
||||
description: "Respect existing tags"
|
||||
required: false
|
||||
debugmode:
|
||||
description: "Debug mode"
|
||||
required: false
|
||||
outputs:
|
||||
semantic_version:
|
||||
description: 'Calculated semantic version'
|
||||
description: "Calculated semantic version"
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: Dockerfile
|
||||
using: "docker"
|
||||
image: "docker://ghcr.io/lukaszraczylo/semver-generator:latest"
|
||||
|
||||
+22
-18
@@ -6,18 +6,22 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/lukaszraczylo/ask"
|
||||
graphql "github.com/lukaszraczylo/go-simple-graphql"
|
||||
libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
|
||||
"github.com/melbahja/got"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func updatePackage() bool {
|
||||
ghToken, ghTokenSet := os.LookupEnv("GITHUB_TOKEN")
|
||||
if ghTokenSet {
|
||||
binaryName := fmt.Sprintf("semver-gen-%s-%s", runtime.GOOS, runtime.GOARCH)
|
||||
fmt.Println("Downloading", binaryName)
|
||||
logger.Info(&libpack_logger.LogMessage{Message: "Checking for updates", Pairs: map[string]interface{}{"binaryName": binaryName}})
|
||||
gql := graphql.NewConnection()
|
||||
gql.Endpoint = "https://api.github.com/graphql"
|
||||
|
||||
gql.SetEndpoint("https://api.github.com/graphql")
|
||||
gql.SetOutput("mapstring")
|
||||
|
||||
headers := map[string]interface{}{
|
||||
"Authorization": fmt.Sprintf("Bearer %s", ghToken),
|
||||
}
|
||||
@@ -40,36 +44,36 @@ func updatePackage() bool {
|
||||
}`
|
||||
result, err := gql.Query(query, variables, headers)
|
||||
if err != nil {
|
||||
fmt.Println("Query error", err)
|
||||
logger.Error(&libpack_logger.LogMessage{Message: "Unable to query GitHub API", Pairs: map[string]interface{}{"error": err.Error()}})
|
||||
return false
|
||||
}
|
||||
|
||||
result = gjson.Get(result, "repository.latestRelease.releaseAssets.edges.0.node.downloadUrl").String()
|
||||
if result == "" {
|
||||
fmt.Println("Unable to obtain download url for the binary", binaryName)
|
||||
output, ok := ask.For(result, "repository.latestRelease.releaseAssets.edges[0].node.downloadUrl").String("")
|
||||
if !ok {
|
||||
logger.Error(&libpack_logger.LogMessage{Message: "Unable to obtain download url for the binary", Pairs: map[string]interface{}{"binary": binaryName, "output": output}})
|
||||
return false
|
||||
}
|
||||
if flag.Lookup("test.v") == nil && os.Getenv("CI") == "" {
|
||||
downloadedBinaryPath := fmt.Sprintf("/tmp/%s", binaryName)
|
||||
g := got.New()
|
||||
err = g.Download(result, downloadedBinaryPath)
|
||||
err = g.Download(output, downloadedBinaryPath)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to download binary", err.Error())
|
||||
logger.Error(&libpack_logger.LogMessage{Message: "Unable to download binary", Pairs: map[string]interface{}{"error": err.Error(), "binaryPath": downloadedBinaryPath}})
|
||||
return false
|
||||
}
|
||||
currentBinary, err := os.Executable()
|
||||
if err != nil {
|
||||
fmt.Println("Unable to obtain current binary path", err.Error())
|
||||
logger.Error(&libpack_logger.LogMessage{Message: "Unable to obtain current binary path", Pairs: map[string]interface{}{"error": err.Error()}})
|
||||
return false
|
||||
}
|
||||
err = os.Rename(downloadedBinaryPath, currentBinary)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to overwrite current binary", err.Error())
|
||||
logger.Error(&libpack_logger.LogMessage{Message: "Unable to overwrite current binary", Pairs: map[string]interface{}{"error": err.Error()}})
|
||||
return false
|
||||
}
|
||||
err = os.Chmod(currentBinary, 0777)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to make binary executable", err.Error())
|
||||
logger.Error(&libpack_logger.LogMessage{Message: "Unable to make binary executable", Pairs: map[string]interface{}{"error": err.Error()}})
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -81,7 +85,7 @@ func checkLatestRelease() (string, bool) {
|
||||
ghToken, ghTokenSet := os.LookupEnv("GITHUB_TOKEN")
|
||||
if ghTokenSet {
|
||||
gql := graphql.NewConnection()
|
||||
gql.Endpoint = "https://api.github.com/graphql"
|
||||
gql.SetEndpoint("https://api.github.com/graphql")
|
||||
headers := map[string]interface{}{
|
||||
"Authorization": fmt.Sprintf("bearer %s", ghToken),
|
||||
}
|
||||
@@ -99,14 +103,14 @@ func checkLatestRelease() (string, bool) {
|
||||
}`
|
||||
result, err := gql.Query(query, variables, headers)
|
||||
if err != nil {
|
||||
fmt.Println("Query error >>", err)
|
||||
logger.Error(&libpack_logger.LogMessage{Message: "Unable to query GitHub API", Pairs: map[string]interface{}{"error": err.Error()}})
|
||||
return "", false
|
||||
}
|
||||
result = gjson.Get(result, "repository.releases.nodes.0.tag.name").String()
|
||||
if result == "v1" {
|
||||
result = gjson.Get(result, "repository.releases.nodes.1.tag.name").String()
|
||||
output, _ := ask.For(result, "repository.releases.nodes[0].tag.name").String("")
|
||||
if output == "v1" {
|
||||
output, _ = ask.For(result, "repository.releases.nodes[1].tag.name").String("")
|
||||
}
|
||||
return result, true
|
||||
return output, true
|
||||
} else {
|
||||
return "[no GITHUB_TOKEN set]", false
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ package cmd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
libpack_logging "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
|
||||
)
|
||||
|
||||
func Test_checkLatestRelease(t *testing.T) {
|
||||
logger = libpack_logging.New()
|
||||
tests := []struct {
|
||||
name string
|
||||
want string
|
||||
@@ -26,6 +29,7 @@ func Test_checkLatestRelease(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_updatePackage(t *testing.T) {
|
||||
logger = libpack_logging.New()
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping test in short / CI mode")
|
||||
}
|
||||
|
||||
+118
-49
@@ -1,3 +1,4 @@
|
||||
// Project: semver-generator
|
||||
/*
|
||||
Copyright © 2021 LUKASZ RACZYLO <lukasz$raczylo,com>
|
||||
|
||||
@@ -17,7 +18,6 @@ limitations under the License.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||
"github.com/lithammer/fuzzysearch/fuzzy"
|
||||
libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
|
||||
"github.com/lukaszraczylo/pandati"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@@ -40,6 +41,7 @@ var (
|
||||
err error
|
||||
repo *Setup
|
||||
PKG_VERSION string
|
||||
logger *libpack_logger.Logger
|
||||
)
|
||||
|
||||
type Wording struct {
|
||||
@@ -50,10 +52,10 @@ type Wording struct {
|
||||
}
|
||||
|
||||
type Force struct {
|
||||
Commit string
|
||||
Patch int
|
||||
Minor int
|
||||
Major int
|
||||
Commit string
|
||||
Existing bool
|
||||
Strict bool
|
||||
}
|
||||
@@ -67,24 +69,25 @@ type SemVer struct {
|
||||
}
|
||||
|
||||
type Setup struct {
|
||||
RepositoryName string
|
||||
RepositoryLocalPath string
|
||||
RepositoryHandler *git.Repository
|
||||
RepositoryName string
|
||||
RepositoryBranch string
|
||||
RepositoryLocalPath string
|
||||
LocalConfigFile string
|
||||
Wording Wording
|
||||
Commits []CommitDetails
|
||||
Tags []TagDetails
|
||||
Semver SemVer
|
||||
Wording Wording
|
||||
Force Force
|
||||
Semver SemVer
|
||||
Generate bool
|
||||
LocalConfigFile string
|
||||
UseLocal bool
|
||||
}
|
||||
|
||||
type CommitDetails struct {
|
||||
Timestamp time.Time
|
||||
Hash string
|
||||
Author string
|
||||
Message string
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
type TagDetails struct {
|
||||
@@ -94,34 +97,38 @@ type TagDetails struct {
|
||||
|
||||
func checkMatches(content []string, targets []string) bool {
|
||||
if fuzzy.MatchNormalizedFold(strings.Join(content, " "), "Merge branch") {
|
||||
debugPrint(fmt.Sprintln("Merge detected, ignoring commits within:", content))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Merge detected, ignoring commits within",
|
||||
Pairs: map[string]interface{}{"content": strings.Join(content, " ")},
|
||||
})
|
||||
return false
|
||||
}
|
||||
var r []string
|
||||
for _, tgt := range targets {
|
||||
r = fuzzy.FindNormalizedFold(tgt, content)
|
||||
r := fuzzy.FindNormalizedFold(tgt, content)
|
||||
if len(r) > 0 {
|
||||
debugPrint(fmt.Sprintln("Found match for ", tgt, "|", strings.Join(r, ",")))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Found match",
|
||||
Pairs: map[string]interface{}{"target": tgt, "match": strings.Join(r, ","), "content": strings.Join(content, " ")},
|
||||
})
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func debugPrint(content string) {
|
||||
if params.varDebug && flag.Lookup("test.v") == nil {
|
||||
fmt.Println("DEBUG:", content)
|
||||
}
|
||||
}
|
||||
|
||||
var extractNumber = regexp.MustCompile("[0-9]+")
|
||||
|
||||
func parseExistingSemver(tagName string, currentSemver SemVer) (semanticVersion SemVer) {
|
||||
debugPrint(fmt.Sprintln("Parsing existing semver:", tagName))
|
||||
var tagNameParts []string
|
||||
tagNameParts = strings.Split(tagName, ".")
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Parsing existing semver",
|
||||
Pairs: map[string]interface{}{"tag": tagName},
|
||||
})
|
||||
tagNameParts := strings.Split(tagName, ".")
|
||||
if len(tagNameParts) < 3 {
|
||||
debugPrint("Unable to parse incompatible semver ( non x.y.z )")
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Unable to parse incompatible semver ( non x.y.z )",
|
||||
Pairs: map[string]interface{}{"tag": tagName},
|
||||
})
|
||||
return currentSemver
|
||||
}
|
||||
semanticVersion.Major, _ = strconv.Atoi(extractNumber.FindAllString(tagNameParts[0], -1)[0])
|
||||
@@ -139,7 +146,10 @@ func (s *Setup) CalculateSemver() SemVer {
|
||||
if params.varExisting || s.Force.Existing {
|
||||
for _, tagHash := range s.Tags {
|
||||
if commit.Hash == tagHash.Hash {
|
||||
debugPrint(fmt.Sprintln("Found existing tag:", tagHash.Name, "related to", commit.Message))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Found existing tag",
|
||||
Pairs: map[string]interface{}{"tag": tagHash.Name, "commit": strings.TrimSuffix(commit.Message, "\n")},
|
||||
})
|
||||
s.Semver = parseExistingSemver(tagHash.Name, s.Semver)
|
||||
continue
|
||||
}
|
||||
@@ -148,7 +158,10 @@ func (s *Setup) CalculateSemver() SemVer {
|
||||
|
||||
if !params.varStrict && !s.Force.Strict {
|
||||
s.Semver.Patch++
|
||||
debugPrint(fmt.Sprintln("Incrementing patch (DEFAULT) on ", strings.TrimSuffix(commit.Message, "\n"), "| Semver:", s.getSemver()))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Incrementing patch (DEFAULT)",
|
||||
Pairs: map[string]interface{}{"commit": strings.TrimSuffix(commit.Message, "\n"), "semver": s.getSemver()},
|
||||
})
|
||||
}
|
||||
commitSlice := strings.Fields(commit.Message)
|
||||
matchPatch := checkMatches(commitSlice, s.Wording.Patch)
|
||||
@@ -157,14 +170,20 @@ func (s *Setup) CalculateSemver() SemVer {
|
||||
matchReleaseCandidate := checkMatches(commitSlice, s.Wording.Release)
|
||||
if matchPatch {
|
||||
s.Semver.Patch++
|
||||
debugPrint(fmt.Sprintln("Incrementing patch (WORDING) on ", strings.TrimSuffix(commit.Message, "\n"), "| Semver:", s.getSemver()))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Incrementing patch (WORDING)",
|
||||
Pairs: map[string]interface{}{"commit": strings.TrimSuffix(commit.Message, "\n"), "semver": s.getSemver()},
|
||||
})
|
||||
continue
|
||||
}
|
||||
if matchReleaseCandidate {
|
||||
s.Semver.Release++
|
||||
s.Semver.Patch = 1
|
||||
s.Semver.EnableReleaseCandidate = true
|
||||
debugPrint(fmt.Sprintln("Incrementing release candidate (WORDING) on ", strings.TrimSuffix(commit.Message, "\n"), "| Semver:", s.getSemver()))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Incrementing release candidate (WORDING)",
|
||||
Pairs: map[string]interface{}{"commit": strings.TrimSuffix(commit.Message, "\n"), "semver": s.getSemver()},
|
||||
})
|
||||
continue
|
||||
}
|
||||
if matchMinor {
|
||||
@@ -172,7 +191,10 @@ func (s *Setup) CalculateSemver() SemVer {
|
||||
s.Semver.Patch = 1
|
||||
s.Semver.EnableReleaseCandidate = false
|
||||
s.Semver.Release = 0
|
||||
debugPrint(fmt.Sprintln("Incrementing minor (WORDING) on ", strings.TrimSuffix(commit.Message, "\n"), "| Semver:", s.getSemver()))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Incrementing minor (WORDING)",
|
||||
Pairs: map[string]interface{}{"commit": strings.TrimSuffix(commit.Message, "\n"), "semver": s.getSemver()},
|
||||
})
|
||||
continue
|
||||
}
|
||||
if matchMajor {
|
||||
@@ -181,7 +203,10 @@ func (s *Setup) CalculateSemver() SemVer {
|
||||
s.Semver.Patch = 1
|
||||
s.Semver.EnableReleaseCandidate = false
|
||||
s.Semver.Release = 0
|
||||
debugPrint(fmt.Sprintln("Incrementing major (WORDING) on ", strings.TrimSuffix(commit.Message, "\n"), "| Semver:", s.getSemver()))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Incrementing major (WORDING)",
|
||||
Pairs: map[string]interface{}{"commit": strings.TrimSuffix(commit.Message, "\n"), "semver": s.getSemver()},
|
||||
})
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -189,14 +214,19 @@ func (s *Setup) CalculateSemver() SemVer {
|
||||
}
|
||||
|
||||
func (s *Setup) ListExistingTags() {
|
||||
debugPrint(fmt.Sprintln("Listing existing tags"))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Listing existing tags",
|
||||
})
|
||||
refs, err := s.RepositoryHandler.Tags()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := refs.ForEach(func(ref *plumbing.Reference) error {
|
||||
s.Tags = append(s.Tags, TagDetails{Name: ref.Name().Short(), Hash: ref.Hash().String()})
|
||||
debugPrint(fmt.Sprintln("Found tag:", ref.Name().Short(), ref.Hash().String()))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Found tag",
|
||||
Pairs: map[string]interface{}{"tag": ref.Name().Short(), "hash": ref.Hash().String()},
|
||||
})
|
||||
return nil
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
@@ -223,11 +253,16 @@ func (s *Setup) ListCommits() ([]CommitDetails, error) {
|
||||
return nil
|
||||
})
|
||||
|
||||
debugPrint(fmt.Sprintln("\n---COMMITS BEFORE CUT---\n", s.Commits))
|
||||
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Listing commits",
|
||||
Pairs: map[string]interface{}{"commits": tmpResults},
|
||||
})
|
||||
for commitId, cmt := range tmpResults {
|
||||
if s.Force.Commit != "" && cmt.Hash == s.Force.Commit {
|
||||
debugPrint(fmt.Sprintln(">>>> FOUND MATCH", len(s.Commits), len(tmpResults[commitId:])))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Found commit match",
|
||||
Pairs: map[string]interface{}{"commit": cmt.Hash, "index": commitId},
|
||||
})
|
||||
s.Commits = tmpResults[commitId:]
|
||||
break
|
||||
} else {
|
||||
@@ -235,7 +270,10 @@ func (s *Setup) ListCommits() ([]CommitDetails, error) {
|
||||
}
|
||||
}
|
||||
|
||||
debugPrint(fmt.Sprintln("\n---COMMITS AFTER CUT---\n", s.Commits))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Commits after cut",
|
||||
Pairs: map[string]interface{}{"commits": s.Commits},
|
||||
})
|
||||
return s.Commits, err
|
||||
}
|
||||
|
||||
@@ -243,13 +281,18 @@ func (s *Setup) Prepare() error {
|
||||
if !repo.UseLocal {
|
||||
u, err := url.Parse(s.RepositoryName)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to parse repository URL", s.RepositoryName, "Error:", err.Error())
|
||||
logger.Error(&libpack_logger.LogMessage{
|
||||
Message: "Unable to parse repository URL",
|
||||
Pairs: map[string]interface{}{"error": err.Error(), "url": s.RepositoryName},
|
||||
})
|
||||
return err
|
||||
}
|
||||
s.RepositoryLocalPath = fmt.Sprintf("/tmp/semver/%s", u.Path)
|
||||
s.RepositoryLocalPath = fmt.Sprintf("/tmp/semver/%s/%s", u.Path, s.RepositoryBranch)
|
||||
os.RemoveAll(s.RepositoryLocalPath)
|
||||
s.RepositoryHandler, err = git.PlainClone(s.RepositoryLocalPath, false, &git.CloneOptions{
|
||||
URL: s.RepositoryName,
|
||||
URL: s.RepositoryName,
|
||||
ReferenceName: plumbing.NewBranchReferenceName(s.RepositoryBranch),
|
||||
SingleBranch: true,
|
||||
Auth: &http.BasicAuth{
|
||||
Username: os.Getenv("GITHUB_USERNAME"),
|
||||
Password: os.Getenv("GITHUB_TOKEN"),
|
||||
@@ -257,14 +300,20 @@ func (s *Setup) Prepare() error {
|
||||
Tags: git.AllTags,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("Unable to reach repository", s.RepositoryName, "Error:", err.Error())
|
||||
logger.Error(&libpack_logger.LogMessage{
|
||||
Message: "Unable to clone repository",
|
||||
Pairs: map[string]interface{}{"error": err.Error(), "url": s.RepositoryName},
|
||||
})
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
s.RepositoryLocalPath = "./"
|
||||
s.RepositoryHandler, err = git.PlainOpen(s.RepositoryLocalPath)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to reach repository", s.RepositoryName, "Error:", err.Error())
|
||||
logger.Error(&libpack_logger.LogMessage{
|
||||
Message: "Unable to open local repository",
|
||||
Pairs: map[string]interface{}{"error": err.Error(), "path": s.RepositoryLocalPath},
|
||||
})
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -274,15 +323,24 @@ func (s *Setup) Prepare() error {
|
||||
|
||||
func (s *Setup) ForcedVersioning() {
|
||||
if !pandati.IsZero(s.Force.Major) {
|
||||
debugPrint(fmt.Sprintln("Forced versioning (MAJOR)", s.Force.Major))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Forced versioning (MAJOR)",
|
||||
Pairs: map[string]interface{}{"major": s.Force.Major},
|
||||
})
|
||||
s.Semver.Major = s.Force.Major
|
||||
}
|
||||
if !pandati.IsZero(s.Force.Minor) {
|
||||
debugPrint(fmt.Sprintln("Forced versioning (MINOR)", s.Force.Minor))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Forced versioning (MINOR)",
|
||||
Pairs: map[string]interface{}{"minor": s.Force.Minor},
|
||||
})
|
||||
s.Semver.Minor = s.Force.Minor
|
||||
}
|
||||
if !pandati.IsZero(s.Force.Patch) {
|
||||
debugPrint(fmt.Sprintln("Forced versioning (PATCH)", s.Force.Patch))
|
||||
logger.Debug(&libpack_logger.LogMessage{
|
||||
Message: "Forced versioning (PATCH)",
|
||||
Pairs: map[string]interface{}{"patch": s.Force.Minor},
|
||||
})
|
||||
s.Semver.Patch = s.Force.Patch
|
||||
}
|
||||
}
|
||||
@@ -291,7 +349,7 @@ func (s *Setup) ReadConfig(file string) error {
|
||||
viper.SetConfigFile(file)
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Fatal error config file: %s \n", err)
|
||||
err = fmt.Errorf("fatal error config file: %s", err)
|
||||
return err
|
||||
}
|
||||
viper.UnmarshalKey("wording", &s.Wording)
|
||||
@@ -308,15 +366,22 @@ func (s *Setup) getSemver() (semverReturned string) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
logger = libpack_logger.New()
|
||||
if params.varShowVersion {
|
||||
var outdatedMsg string
|
||||
latestRelease, latestRelaseOk := checkLatestRelease()
|
||||
if PKG_VERSION != latestRelease && latestRelaseOk {
|
||||
outdatedMsg = fmt.Sprintf("(Latest available: %s)", latestRelease)
|
||||
}
|
||||
fmt.Println("semver-gen", PKG_VERSION, "", outdatedMsg, "\tMore information: https://github.com/lukaszraczylo/semver-generator")
|
||||
logger.Info(&libpack_logger.LogMessage{
|
||||
Message: "semver-gen",
|
||||
Pairs: map[string]interface{}{"version": PKG_VERSION, "outdated": outdatedMsg},
|
||||
})
|
||||
if outdatedMsg != "" {
|
||||
fmt.Println("You can update automatically with: semver-gen -u")
|
||||
logger.Info(&libpack_logger.LogMessage{
|
||||
Message: "semver-gen",
|
||||
Pairs: map[string]interface{}{"message": "You can update automatically with: semver-gen -u"},
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -327,13 +392,17 @@ func main() {
|
||||
if repo.Generate || params.varGenerateInTest {
|
||||
err := repo.ReadConfig(repo.LocalConfigFile)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to find config file", repo.LocalConfigFile)
|
||||
os.Exit(1)
|
||||
logger.Error(&libpack_logger.LogMessage{
|
||||
Message: "Unable to find config file semver.yaml. Using defaults and flags.",
|
||||
Pairs: map[string]interface{}{"file": repo.LocalConfigFile},
|
||||
})
|
||||
}
|
||||
err = repo.Prepare()
|
||||
if err != nil {
|
||||
fmt.Println("Unable to prepare repository")
|
||||
os.Exit(1)
|
||||
logger.Critical(&libpack_logger.LogMessage{
|
||||
Message: "Unable to prepare repository",
|
||||
Pairs: map[string]interface{}{"error": err.Error()},
|
||||
})
|
||||
}
|
||||
repo.ListCommits()
|
||||
if params.varExisting || repo.Force.Existing {
|
||||
|
||||
+85
-36
@@ -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,
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"testing"
|
||||
|
||||
git "github.com/go-git/go-git/v5"
|
||||
libpack_logging "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
|
||||
"github.com/lukaszraczylo/pandati"
|
||||
assertions "github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@@ -36,12 +37,17 @@ var (
|
||||
)
|
||||
|
||||
func (suite *Tests) SetupTest() {
|
||||
os.Chdir(testCurrentPath)
|
||||
err := os.Chdir(testCurrentPath)
|
||||
if err != nil {
|
||||
logger.Critical(&libpack_logging.LogMessage{Message: "Unable to change directory to test directory", Pairs: map[string]any{"error": err}})
|
||||
}
|
||||
assert = assertions.New(suite.T())
|
||||
params.varDebug = true
|
||||
params.varRepoBranch = "main"
|
||||
}
|
||||
|
||||
func TestSuite(t *testing.T) {
|
||||
logger = libpack_logging.New()
|
||||
testCurrentPath, _ = os.Getwd()
|
||||
suite.Run(t, new(Tests))
|
||||
}
|
||||
@@ -52,8 +58,8 @@ func (suite *Tests) TestSetup_getSemver() {
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
fields fields
|
||||
}{
|
||||
{
|
||||
name: "Return 1.3.7",
|
||||
@@ -106,13 +112,13 @@ func (suite *Tests) TestSetup_getSemver() {
|
||||
|
||||
func (suite *Tests) TestSetup_ForcedVersioning() {
|
||||
type fields struct {
|
||||
Semver SemVer
|
||||
Force Force
|
||||
Semver SemVer
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
fields fields
|
||||
}{
|
||||
{
|
||||
name: "No versioning",
|
||||
@@ -211,8 +217,8 @@ func (suite *Tests) TestSetup_ReadConfig() {
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
fields fields
|
||||
wordingEmpty bool
|
||||
wantErr bool
|
||||
}{
|
||||
@@ -284,14 +290,15 @@ func (suite *Tests) Test_checkMatches() {
|
||||
|
||||
func (suite *Tests) TestSetup_ListCommits() {
|
||||
type fields struct {
|
||||
RepositoryName string
|
||||
RepositoryLocalPath string
|
||||
RepositoryHandler *git.Repository
|
||||
RepositoryName string
|
||||
RepositoryBranch string
|
||||
RepositoryLocalPath string
|
||||
LocalConfigFile string
|
||||
Commits []CommitDetails
|
||||
Semver SemVer
|
||||
Wording Wording
|
||||
Commits []CommitDetails
|
||||
Force Force
|
||||
Semver SemVer
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@@ -303,7 +310,8 @@ func (suite *Tests) TestSetup_ListCommits() {
|
||||
{
|
||||
name: "List commits from existing repository",
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
|
||||
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
|
||||
RepositoryBranch: "master",
|
||||
},
|
||||
noCommits: false,
|
||||
wantErr: false,
|
||||
@@ -311,7 +319,8 @@ func (suite *Tests) TestSetup_ListCommits() {
|
||||
{
|
||||
name: "List commits from non-existing repository",
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client-dead",
|
||||
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client-dead",
|
||||
RepositoryBranch: "main",
|
||||
},
|
||||
noCommits: true,
|
||||
wantErr: true,
|
||||
@@ -319,7 +328,8 @@ func (suite *Tests) TestSetup_ListCommits() {
|
||||
{
|
||||
name: "List commits starting with certain hash",
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
|
||||
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
|
||||
RepositoryBranch: "master",
|
||||
Force: Force{
|
||||
Commit: "f6ee82113afb32ee95eac892d1155582a2f85166",
|
||||
},
|
||||
@@ -333,6 +343,7 @@ func (suite *Tests) TestSetup_ListCommits() {
|
||||
s := &Setup{}
|
||||
s.ReadConfig(tt.fields.LocalConfigFile)
|
||||
s.RepositoryName = tt.fields.RepositoryName
|
||||
s.RepositoryBranch = tt.fields.RepositoryBranch
|
||||
s.Force = tt.fields.Force
|
||||
s.Prepare()
|
||||
listOfCommits, err := s.ListCommits()
|
||||
@@ -349,8 +360,9 @@ func (suite *Tests) TestSetup_ListCommits() {
|
||||
func (suite *Tests) TestSetup_CalculateSemver() {
|
||||
type fields struct {
|
||||
RepositoryName string
|
||||
Force Force
|
||||
BranchName string
|
||||
LocalConfigFile string
|
||||
Force Force
|
||||
}
|
||||
type wantSemver struct {
|
||||
Major int
|
||||
@@ -368,6 +380,7 @@ func (suite *Tests) TestSetup_CalculateSemver() {
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/semver-generator-test-repo",
|
||||
LocalConfigFile: "meta.yaml",
|
||||
BranchName: "main",
|
||||
},
|
||||
strictMatching: false,
|
||||
wantSemver: wantSemver{
|
||||
@@ -381,6 +394,7 @@ func (suite *Tests) TestSetup_CalculateSemver() {
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/semver-generator-test-repo",
|
||||
LocalConfigFile: "meta.yaml",
|
||||
BranchName: "main",
|
||||
},
|
||||
strictMatching: true,
|
||||
wantSemver: wantSemver{
|
||||
@@ -394,6 +408,7 @@ func (suite *Tests) TestSetup_CalculateSemver() {
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/semver-generator-test-repo",
|
||||
LocalConfigFile: "meta.yaml",
|
||||
BranchName: "main",
|
||||
Force: Force{
|
||||
Major: 1,
|
||||
Minor: 1,
|
||||
@@ -412,6 +427,7 @@ func (suite *Tests) TestSetup_CalculateSemver() {
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/semver-generator-test-repo",
|
||||
LocalConfigFile: "meta.yaml",
|
||||
BranchName: "main",
|
||||
Force: Force{
|
||||
Major: 1,
|
||||
Minor: 1,
|
||||
@@ -442,6 +458,7 @@ func (suite *Tests) TestSetup_CalculateSemver() {
|
||||
s := &Setup{}
|
||||
s.ReadConfig(tt.fields.LocalConfigFile)
|
||||
s.RepositoryName = tt.fields.RepositoryName
|
||||
s.RepositoryBranch = tt.fields.BranchName
|
||||
s.Prepare()
|
||||
s.ForcedVersioning()
|
||||
s.Force = tt.fields.Force
|
||||
@@ -455,31 +472,10 @@ func (suite *Tests) TestSetup_CalculateSemver() {
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *Tests) Test_debugPrint() {
|
||||
type args struct {
|
||||
content string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
}{
|
||||
{
|
||||
name: "Test debug print",
|
||||
args: args{
|
||||
content: "Test debug",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
suite.T().Run(tt.name, func(t *testing.T) {
|
||||
debugPrint(tt.args.content)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *Tests) Test_main() {
|
||||
type vars struct {
|
||||
varRepoName string
|
||||
varRepoBranch string
|
||||
varLocalCfg string
|
||||
varUseLocal bool
|
||||
varShowVersion bool
|
||||
@@ -581,3 +577,56 @@ func (suite *Tests) Test_parseExistingSemver() {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *Tests) TestSetup_ListExistingTags() {
|
||||
type fields struct {
|
||||
RepositoryHandler *git.Repository
|
||||
RepositoryName string
|
||||
RepositoryBranch string
|
||||
RepositoryLocalPath string
|
||||
LocalConfigFile string
|
||||
Wording Wording
|
||||
Commits []CommitDetails
|
||||
Force Force
|
||||
Semver SemVer
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
noTags bool
|
||||
}{
|
||||
{
|
||||
name: "List tags from existing repository",
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
|
||||
RepositoryBranch: "master",
|
||||
},
|
||||
noTags: false,
|
||||
},
|
||||
{
|
||||
name: "List tags from non-existing repository",
|
||||
fields: fields{
|
||||
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client-dead",
|
||||
RepositoryBranch: "master",
|
||||
},
|
||||
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.RepositoryBranch = tt.fields.RepositoryBranch
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -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,
|
||||
@@ -41,6 +41,10 @@ func (r *Setup) setupCobra() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.RepositoryBranch, err = rootCmd.Flags().GetString("branch")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.LocalConfigFile, err = rootCmd.Flags().GetString("config")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -53,6 +57,7 @@ func (r *Setup) setupCobra() {
|
||||
|
||||
type myParams struct {
|
||||
varRepoName string
|
||||
varRepoBranch string
|
||||
varLocalCfg string
|
||||
varUseLocal bool
|
||||
varShowVersion bool
|
||||
@@ -69,6 +74,7 @@ func init() {
|
||||
repo = &Setup{}
|
||||
cobra.OnInitialize(repo.setupCobra)
|
||||
rootCmd.PersistentFlags().StringVarP(¶ms.varRepoName, "repository", "r", "https://github.com/lukaszraczylo/simple-gql-client", "Remote repository URL.")
|
||||
rootCmd.PersistentFlags().StringVarP(¶ms.varRepoBranch, "branch", "b", "main", "Remote repository URL Branch.")
|
||||
rootCmd.PersistentFlags().StringVarP(¶ms.varLocalCfg, "config", "c", "semver.yaml", "Path to config file")
|
||||
rootCmd.PersistentFlags().BoolVarP(¶ms.varUseLocal, "local", "l", false, "Use local repository")
|
||||
rootCmd.PersistentFlags().BoolVarP(¶ms.varShowVersion, "version", "v", false, "Display version")
|
||||
|
||||
+36
-6
@@ -1,10 +1,11 @@
|
||||
#!/bin/sh -l
|
||||
set -o pipefail
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
FLAGS=""
|
||||
FLAGS="$SEMVER_RAW_FLAGS"
|
||||
|
||||
if [[ -z "$INPUT_CONFIG_FILE" ]]; then
|
||||
echo "Set the configuration file path."
|
||||
exit 1
|
||||
else
|
||||
FLAGS="${FLAGS} -c $INPUT_CONFIG_FILE"
|
||||
fi
|
||||
@@ -18,10 +19,26 @@ if [[ ! -z "$INPUT_REPOSITORY_URL" ]]; then
|
||||
FLAGS="${FLAGS} -r $INPUT_REPOSITORY_URL"
|
||||
fi
|
||||
|
||||
if [[ ! -z "$INPUT_REPOSITORY_BRANCH" ]]; then
|
||||
FLAGS="${FLAGS} -b $INPUT_REPOSITORY_BRANCH"
|
||||
fi
|
||||
|
||||
if [[ ! -z "$INPUT_REPOSITORY_LOCAL" ]]; then
|
||||
FLAGS="${FLAGS} -l"
|
||||
fi
|
||||
|
||||
if [[ ! -z "$INPUT_STRICT" ]]; then
|
||||
FLAGS="${FLAGS} -s"
|
||||
fi
|
||||
|
||||
if [[ ! -z "$INPUT_EXISTING" ]]; then
|
||||
FLAGS="${FLAGS} -e"
|
||||
fi
|
||||
|
||||
if [[ ! -z "$INPUT_DEBUGMODE" ]]; then
|
||||
FLAGS="${FLAGS} --debug"
|
||||
fi
|
||||
|
||||
if [[ "${FLAGS}" == "" && "$*" == "" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
@@ -34,8 +51,21 @@ if [[ ! -z "$INPUT_GITHUB_USERNAME" ]]; then
|
||||
export GITHUB_USERNAME=$INPUT_GITHUB_USERNAME
|
||||
fi
|
||||
|
||||
cd /github/workspace
|
||||
if [[ ! -z "$INPUT_DEBUGMODE" ]]; then
|
||||
echo "DEBUG MODE ENABLED"
|
||||
echo "----"
|
||||
ls -lA
|
||||
echo "----"
|
||||
pwd
|
||||
echo "----"
|
||||
echo "FLAGS: $FLAGS"
|
||||
echo "----"
|
||||
/go/src/app/semver-gen generate $FLAGS $*
|
||||
echo "----"
|
||||
fi
|
||||
|
||||
OUT_SEMVER_GEN=$(/go/src/app/semver-gen generate $FLAGS $*)
|
||||
[ $? -eq 0 ] || exit 1
|
||||
echo "::set-output name=semantic_version::$(echo $OUT_SEMVER_GEN | sed -e 's|SEMVER ||g')"
|
||||
echo $OUT_SEMVER_GEN
|
||||
CLEAN_SEMVER=$(echo $OUT_SEMVER_GEN | sed -e 's|SEMVER ||g')
|
||||
echo "semantic_version=$CLEAN_SEMVER" >> $GITHUB_OUTPUT
|
||||
echo $OUT_SEMVER_GEN
|
||||
|
||||
@@ -1,58 +1,75 @@
|
||||
module github.com/lukaszraczylo/semver-generator
|
||||
|
||||
go 1.17
|
||||
go 1.22.7
|
||||
|
||||
toolchain go1.23.4
|
||||
|
||||
require (
|
||||
github.com/go-git/go-git/v5 v5.4.2
|
||||
github.com/lithammer/fuzzysearch v1.1.3
|
||||
github.com/lukaszraczylo/go-simple-graphql v1.0.50
|
||||
github.com/lukaszraczylo/pandati v0.0.10
|
||||
github.com/melbahja/got v0.6.1
|
||||
github.com/spf13/cobra v1.3.0
|
||||
github.com/spf13/viper v1.10.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tidwall/gjson v1.14.0
|
||||
github.com/go-git/go-git/v5 v5.13.2
|
||||
github.com/lithammer/fuzzysearch v1.1.8
|
||||
github.com/lukaszraczylo/ask v0.0.0-20240916204100-6e9ef53a62d9
|
||||
github.com/lukaszraczylo/go-simple-graphql v1.2.41
|
||||
github.com/lukaszraczylo/graphql-monitoring-proxy v0.25.126
|
||||
github.com/lukaszraczylo/pandati v0.0.29
|
||||
github.com/melbahja/got v0.7.0
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/viper v1.19.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.5.1 // indirect
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f // indirect
|
||||
github.com/acomagu/bufpipe v1.0.3 // indirect
|
||||
github.com/allegro/bigcache/v3 v3.0.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/emirpasic/gods v1.12.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.1 // indirect
|
||||
github.com/go-git/gcfg v1.5.0 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.3.1 // indirect
|
||||
dario.cat/mergo v1.0.1 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/ProtonMail/go-crypto v1.1.5 // indirect
|
||||
github.com/avast/retry-go/v4 v4.6.0 // indirect
|
||||
github.com/cloudflare/circl v1.6.0 // indirect
|
||||
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.6.2 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
||||
github.com/gookit/color v1.5.4 // indirect
|
||||
github.com/gookit/goutil v0.6.18 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // 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 v1.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.5 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml v1.9.4 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rs/zerolog v1.26.1 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/spf13/afero v1.8.1 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/magiconair/properties v1.8.9 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.2 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/rs/zerolog v1.33.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
|
||||
github.com/skeema/knownhosts v1.3.1 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.12.0 // indirect
|
||||
github.com/spf13/cast v1.7.1 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220209195652-db638375bc3a // indirect
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
github.com/wI2L/jsondiff v0.6.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.33.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 // indirect
|
||||
golang.org/x/net v0.34.0 // indirect
|
||||
golang.org/x/sync v0.11.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/term v0.29.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user