Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
[#102]: update(ci): Version value extracting improved
Browse files Browse the repository at this point in the history
update(ci): Version value extracting improved
  • Loading branch information
rustatian authored Sep 24, 2021
2 parents 79bd08f + 79293f7 commit aefc154
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
41 changes: 23 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ jobs:
- name: Download dependencies
run: go mod download # `-x` means "verbose" mode

- uses: gacts/github-slug@v1
id: slug

- name: Generate builder values
id: values
run: |
echo "::set-output name=version::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`"
echo "::set-output name=timestamp::`date +%FT%T%z`"
echo "::set-output name=binary-name::rr`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`"
Expand All @@ -63,7 +65,7 @@ jobs:
CGO_ENABLED: 0
LDFLAGS: >-
-s
-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=${{ steps.values.outputs.version }}
-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=${{ steps.slug.outputs.version }}
-X github.com/spiral/roadrunner-binary/v2/internal/meta.buildTime=${{ steps.values.outputs.timestamp }}
run: |
go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.binary-name }}" ./cmd/rr
Expand All @@ -72,7 +74,7 @@ jobs:
- name: Generate distributive directory name
id: dist-dir
run: >
echo "::set-output name=name::roadrunner-${{ steps.values.outputs.version }}-$(
echo "::set-output name=name::roadrunner-${{ steps.slug.outputs.version }}-$(
[ ${{ matrix.os }} != '' ] && echo '${{ matrix.os }}' || echo 'unknown'
)$(
[ ${{ matrix.compiler }} = 'musl-gcc' ] && echo '-musl'
Expand Down Expand Up @@ -126,6 +128,9 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- uses: gacts/github-slug@v1
id: slug

- name: Set up QEMU
uses: docker/setup-qemu-action@v1 # Action page: <https://github.com/docker/setup-qemu-action>

Expand All @@ -147,20 +152,20 @@ jobs:

- name: Generate builder values
id: values
run: |
echo "::set-output name=version::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`"
echo "::set-output name=timestamp::`date +%FT%T%z`"
run: echo "::set-output name=timestamp::`date +%FT%T%z`"

- name: Build image
run: |
docker buildx build \
--platform "linux/amd64,linux/arm64" \
--tag "spiralscout/roadrunner:latest" \
--tag "spiralscout/roadrunner:${{ steps.values.outputs.version }}" \
--tag "ghcr.io/spiral/roadrunner:latest" \
--tag "ghcr.io/spiral/roadrunner:${{ steps.values.outputs.version }}" \
--build-arg "APP_VERSION=${{ steps.values.outputs.version }}" \
--build-arg "BUILD_TIME=${{ steps.values.outputs.timestamp }}" \
--file ./Dockerfile \
--push \
.
uses: docker/build-push-action@v2 # Action page: <https://github.com/docker/build-push-action>
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
build-args: |
APP_VERSION=${{ steps.slug.outputs.version }}
BUILD_TIME=${{ steps.values.outputs.timestamp }}
tags: |
spiralscout/roadrunner:latest
spiralscout/roadrunner:${{ steps.slug.outputs.version }}
ghcr.io/spiral/roadrunner:latest
ghcr.io/spiral/roadrunner:${{ steps.slug.outputs.version }}
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@ jobs:
- name: Install Go dependencies
run: go mod download && go mod verify

- name: Generate version value
id: values # for PR this value will be `merge@__hash__`, SO: <https://stackoverflow.com/a/59780579/2252921>
run: |
echo "::set-output name=version::`echo ${GITHUB_REF##*/}`@`echo ${GITHUB_SHA} | cut -c1-8`"
echo "::set-output name=timestamp::`date +%FT%T%z`"
- uses: gacts/github-slug@v1
id: slug

- id: values
run: echo "::set-output name=timestamp::`date +%FT%T%z`"

- name: Compile binary file
env:
GOOS: ${{ matrix.os }}
GOARCH: amd64
CGO_ENABLED: 0
LDFLAGS: -s
-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=${{ steps.values.outputs.version }}
-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=${{ steps.slug.outputs.version }}@${{ steps.slug.outputs.commit-hash-short }}
-X github.com/spiral/roadrunner-binary/v2/internal/meta.buildTime=${{ steps.values.outputs.timestamp }}
run: go build -trimpath -ldflags "$LDFLAGS" -o ./rr ./cmd/rr

Expand Down

0 comments on commit aefc154

Please sign in to comment.