mirror of
https://github.com/lukaszraczylo/semver-generator.git
synced 2026-06-20 01:51:22 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
9e54d213a7
|
|||
|
acdc87db7d
|
|||
|
5aaaf3c599
|
|||
|
de8d0dba1d
|
|||
|
b51ea576a3
|
|||
|
a1c81c7120
|
|||
|
2f78fd46ef
|
|||
|
ecd0363c45
|
+61
-103
@@ -117,80 +117,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
args: ./...
|
args: ./...
|
||||||
|
|
||||||
build-docker:
|
|
||||||
needs: [ prepare, test, code_scans ]
|
|
||||||
name: Docker image build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Login to GHCR
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.ACTOR }}
|
|
||||||
password: ${{ secrets.GHCR_TOKEN }}
|
|
||||||
- name: Prepare for push
|
|
||||||
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"
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
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 "LABELS=$LABELS" >> $GITHUB_OUTPUT
|
|
||||||
BUILD_ARGS="BRANCH=$BRANCH"
|
|
||||||
echo "args=$BUILD_ARGS" >> $GITHUB_OUTPUT
|
|
||||||
- name: Build image
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
platforms: linux/arm64,linux/amd64
|
|
||||||
push: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
|
|
||||||
tags: ${{ steps.prep.outputs.tags }}
|
|
||||||
build-args: |
|
|
||||||
GITHUB_AUTH_TOKEN=${{ secrets.GHCR_TOKEN }}
|
|
||||||
MICROSERVICE_NAME=${{ github.event.repository.name }}
|
|
||||||
GITHUB_COMMIT_NUMBER=${{ needs.prepare.outputs.GITHUB_COMMIT_NUMBER }}
|
|
||||||
GITHUB_SHA=${{ needs.prepare.outputs.GITHUB_SHA }}
|
|
||||||
${{ 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: false
|
|
||||||
|
|
||||||
build-binary:
|
build-binary:
|
||||||
needs: [ prepare, test, code_scans ]
|
needs: [ prepare, test, code_scans ]
|
||||||
name: Binary compilation and release
|
name: Binary compilation and release
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -217,47 +149,73 @@ jobs:
|
|||||||
artifacts: "dist/*"
|
artifacts: "dist/*"
|
||||||
allowUpdates: true
|
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]
|
- name: Create release [v1]
|
||||||
uses: ncipollo/release-action@v1
|
uses: ncipollo/release-action@v1
|
||||||
with:
|
with:
|
||||||
bodyFile: ./.release_notes
|
bodyFile: ./.release_notes
|
||||||
name: version ${{ needs.prepare.outputs.RELEASE_VERSION }}
|
name: v1 - ${{ needs.prepare.outputs.RELEASE_VERSION }}
|
||||||
token: ${{ secrets.GHCR_TOKEN }}
|
token: ${{ secrets.GHCR_TOKEN }}
|
||||||
tag: v1
|
tag: v1
|
||||||
prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}
|
prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}
|
||||||
artifacts: "dist/*"
|
artifacts: "dist/*"
|
||||||
allowUpdates: true
|
allowUpdates: true
|
||||||
|
makeLatest: false
|
||||||
|
|
||||||
# - name: Compile and release semver
|
build-docker:
|
||||||
# uses: wangyoucao577/go-release-action@v1.34
|
needs: [ prepare, test, code_scans, build-binary ]
|
||||||
# with:
|
name: Docker image build
|
||||||
# github_token: ${{ secrets.GHCR_TOKEN }}
|
runs-on: ubuntu-latest
|
||||||
# goos: ${{ matrix.goos }}
|
steps:
|
||||||
# goarch: ${{ matrix.goarch }}
|
- name: Checkout repo
|
||||||
# ldflags: -s -w -X main.PKG_VERSION=${{ needs.prepare.outputs.RELEASE_VERSION }}
|
uses: actions/checkout@v3
|
||||||
# project_path: .
|
- name: Set up QEMU
|
||||||
# binary_name: semver-gen
|
uses: docker/setup-qemu-action@v2
|
||||||
# asset_name: semver-gen-${{ matrix.goos }}-${{ matrix.goarch }}
|
- name: Set up Docker Buildx
|
||||||
# release_name: version ${{ needs.prepare.outputs.RELEASE_VERSION }}
|
uses: docker/setup-buildx-action@v2
|
||||||
# release_tag: ${{ needs.prepare.outputs.RELEASE_VERSION }}
|
- name: Login to GHCR
|
||||||
# compress_assets: false
|
if: github.event_name != 'pull_request'
|
||||||
# retry: 10
|
uses: docker/login-action@v2
|
||||||
# overwrite: true
|
with:
|
||||||
# pre_command: export GODEBUG=http2client=0 && export CGO_ENABLED=1 && make update
|
registry: ghcr.io
|
||||||
|
username: ${{ github.ACTOR }}
|
||||||
# - name: Compile and release v1
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
# uses: wangyoucao577/go-release-action@v1.33
|
- name: Prepare for push
|
||||||
# with:
|
id: prep
|
||||||
# github_token: ${{ secrets.GHCR_TOKEN }}
|
run: |
|
||||||
# goos: ${{ matrix.goos }}
|
if [ -z "${{ needs.prepare.outputs.RELEASE_VERSION }}" ]; then
|
||||||
# goarch: ${{ matrix.goarch }}
|
TAGS="${{ needs.prepare.outputs.DOCKER_IMAGE }}:${{ needs.prepare.outputs.GITHUB_SHA }},${{ needs.prepare.outputs.DOCKER_IMAGE }}:latest,${{ needs.prepare.outputs.DOCKER_IMAGE }}:v1"
|
||||||
# ldflags: -s -w -X main.PKG_VERSION=${{ needs.prepare.outputs.RELEASE_VERSION }}
|
else
|
||||||
# project_path: .
|
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"
|
||||||
# binary_name: semver-gen
|
fi
|
||||||
# asset_name: semver-gen-${{ matrix.goos }}-${{ matrix.goarch }}
|
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
|
||||||
# release_name: version v1
|
BRANCH=$(echo ${GITHUB_REF##*/} | tr '[A-Z]' '[a-z]')
|
||||||
# release_tag: v1
|
LABELS="org.opencontainers.image.revision=${{ needs.prepare.outputs.GITHUB_SHA }}"
|
||||||
# compress_assets: false
|
LABELS="$LABELS,org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||||
# retry: 10
|
LABELS="$LABELS,org.opencontainers.image.version=$VERSION"
|
||||||
# overwrite: true
|
LABELS="$LABELS,com.github.repo.branch=$BRANCH"
|
||||||
# pre_command: export GODEBUG=http2client=0 && export CGO_ENABLED=1 && make update
|
LABELS="$LABELS,com.github.repo.dockerfile=Dockerfile"
|
||||||
|
echo "LABELS=$LABELS" >> $GITHUB_OUTPUT
|
||||||
|
BUILD_ARGS="BRANCH=$BRANCH"
|
||||||
|
echo "args=$BUILD_ARGS" >> $GITHUB_OUTPUT
|
||||||
|
- name: Build image
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
platforms: linux/arm64,linux/amd64
|
||||||
|
push: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
|
||||||
|
tags: ${{ steps.prep.outputs.tags }}
|
||||||
|
build-args: |
|
||||||
|
GITHUB_AUTH_TOKEN=${{ secrets.GHCR_TOKEN }}
|
||||||
|
MICROSERVICE_NAME=${{ github.event.repository.name }}
|
||||||
|
GITHUB_COMMIT_NUMBER=${{ needs.prepare.outputs.GITHUB_COMMIT_NUMBER }}
|
||||||
|
GITHUB_SHA=${{ needs.prepare.outputs.GITHUB_SHA }}
|
||||||
|
${{ steps.prep.outputs.args }}
|
||||||
|
labels: ${{ steps.prep.outputs.labels }}
|
||||||
|
no-cache: false
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh -l
|
#!/bin/bash
|
||||||
set -o pipefail
|
set -e
|
||||||
|
|
||||||
FLAGS=""
|
FLAGS=""
|
||||||
|
|
||||||
@@ -37,5 +37,6 @@ fi
|
|||||||
cd /github/workspace
|
cd /github/workspace
|
||||||
OUT_SEMVER_GEN=$(/go/src/app/semver-gen generate $FLAGS $*)
|
OUT_SEMVER_GEN=$(/go/src/app/semver-gen generate $FLAGS $*)
|
||||||
[ $? -eq 0 ] || exit 1
|
[ $? -eq 0 ] || exit 1
|
||||||
echo "::set-output name=semantic_version::$(echo $OUT_SEMVER_GEN | sed -e 's|SEMVER ||g')"
|
CLEAN_SEMVER=$(echo $OUT_SEMVER_GEN | sed -e 's|SEMVER ||g')
|
||||||
|
echo "semantic_version=$CLEAN_SEMVER" >> $GITHUB_OUTPUT
|
||||||
echo $OUT_SEMVER_GEN
|
echo $OUT_SEMVER_GEN
|
||||||
Reference in New Issue
Block a user