rework version and commit logic for CI

pull/1118/head
Willy 2023-02-01 21:49:18 +01:00
parent dfd578140a
commit 9dc4d11e87
No known key found for this signature in database
GPG Key ID: 02E60AE5D9208602
2 changed files with 16 additions and 32 deletions

View File

@ -15,23 +15,24 @@ jobs:
# also, the name is intentionally short to make later references shorter. # also, the name is intentionally short to make later references shorter.
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
version: ${{ steps.version.outputs.version }} is_release: ${{ steps.versions.outputs.is_release }}
is_release: ${{ steps.states.outputs.is_release }} version: ${{ steps.versions.outputs.version }}
is_stable: ${{ steps.states.outputs.is_stable }}
is_unstable: ${{ steps.states.outputs.is_unstable }}
go_version: 1.18.x go_version: 1.18.x
node_version: 16.14.0 node_version: 16.14.0
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: get version
id: version
run: echo "::set-output name=version::$(cat version.txt)"
- name: get stable/unstable states - name: get stable/unstable states
id: states id: versions
run: | run: |
echo "::set-output name=is_release::${{ github.event_name == 'push' && (github.ref == 'refs/heads/stable' || github.ref == 'refs/heads/unstable') }}" TAG=$(git describe --tags)
echo "::set-output name=is_stable::${{ github.event_name == 'push' && github.ref == 'refs/heads/stable' }}" if [ "${{ github.ref }}" = "refs/heads/$TAG"]; then
echo "::set-output name=is_unstable::${{ github.event_name == 'push' && github.ref == 'refs/heads/unstable' }}" echo "is_release=true" >> $GITHUB_OUTPUT
else
echo "is_release=false" >> $GITHUB_OUTPUT
fi
# this will be v1.2.3 for on-tag builds and v1.2.3-numberofcommits-sha for off-tag builds
echo "version=$LAST_TAG" >> $GITHUB_OUTPUT
shell: bash
frontend: frontend:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: data needs: data
@ -140,9 +141,6 @@ jobs:
- name: Build ${{ matrix.platform }}/${{ matrix.arch }} - name: Build ${{ matrix.platform }}/${{ matrix.arch }}
uses: crazy-max/ghaction-xgo@v2 uses: crazy-max/ghaction-xgo@v2
env:
VERSION: ${{ needs.data.outputs.version }}
COMMIT: ${{ github.sha }}
with: with:
xgo_version: latest xgo_version: latest
go_version: ${{ needs.data.outputs.go_version }} go_version: ${{ needs.data.outputs.go_version }}
@ -155,7 +153,7 @@ jobs:
pkg: cmd pkg: cmd
buildmode: pie buildmode: pie
tags: ${{ env.XGO_TAGS }} tags: ${{ env.XGO_TAGS }}
ldflags: -s -w -X main.VERSION=${{ needs.data.outputs.version }} -X main.COMMIT=${{ env.COMMIT }} ${{ env.BUILD_FLAGS }} ldflags: -s -w -X main.VERSION=${{ needs.data.outputs.version }} -X main.COMMIT=${{ github.sha }} ${{ env.BUILD_FLAGS }}
- run: ls -la build - run: ls -la build
@ -253,9 +251,6 @@ jobs:
path: ./source path: ./source
- name: Install Statping - name: Install Statping
env:
VERSION: ${{ needs.data.outputs.version }}
COMMIT: ${{ github.sha }}
run: | run: |
make build certs make build certs
chmod +x statping chmod +x statping
@ -330,9 +325,6 @@ jobs:
path: ./source path: ./source
- name: Install Statping - name: Install Statping
env:
VERSION: ${{ needs.data.outputs.version }}
COMMIT: ${{ github.sha }}
run: | run: |
make build make build
chmod +x statping chmod +x statping
@ -384,10 +376,6 @@ jobs:
- name: Install Statping - name: Install Statping
env: env:
VERSION: ${{ needs.data.outputs.version }}
COMMIT: ${{ github.sha }}
MJML_APP: ${{ secrets.MJML_APP }}
MJML_PRIVATE: ${{ secrets.MJML_PRIVATE }}
run: | run: |
make build make build
chmod +x statping chmod +x statping
@ -439,9 +427,6 @@ jobs:
path: ./source path: ./source
- name: Install Statping - name: Install Statping
env:
VERSION: ${{ needs.data.outputs.version }}
COMMIT: ${{ github.sha }}
run: | run: |
make build make build
chmod +x statping chmod +x statping
@ -470,11 +455,10 @@ jobs:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}
push_strategy: artifact push_strategy: artifact
platforms: linux/amd64 platforms: linux/amd64
# TODO pass version and commit as docker build args
# TODO everything from here on is stable/unstable release only
# all other release jobs should be based on this # all other release jobs should be based on this
release-precondition-check: release:
# only run release jobs on push to stable/unstable. # only run release jobs on push to stable/unstable.
# yes, we need to explicitly compare to 'true' here since it's a string # yes, we need to explicitly compare to 'true' here since it's a string
if: ${{ success() && needs.data.outputs.is_release == 'true' }} if: ${{ success() && needs.data.outputs.is_release == 'true' }}

View File

@ -19,7 +19,7 @@ import (
var ( var (
// VERSION stores the current version of Statping // VERSION stores the current version of Statping
VERSION string VERSION string = "dev"
// COMMIT stores the git commit hash for this version of Statping // COMMIT stores the git commit hash for this version of Statping
COMMIT string COMMIT string
log = utils.Log.WithField("type", "cmd") log = utils.Log.WithField("type", "cmd")