Skip to content

Commit

Permalink
build: Tag release with a stable version (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoshkin authored Apr 11, 2023
1 parent b2c3953 commit 45eea50
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runs:
using: "composite"
steps:
- name: Push job status and other metadata to a remote backend
uses: dkoshkin/status-writer-action@v0.1.0
uses: dkoshkin/status-writer-action@alpha
with:
# select the backend to use
backend: "${{ inputs.backend }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ jobs:
influxdb_bucket: "${{ secrets.INFLUXDB_BUCKET }}"
# set the status and additional metadata tags
repository: "${{ github.repository }}"
status: ${{ job.status }}
status: "${{ job.status }}"
tags: "workflow=${{ github.workflow }},job=${{ github.job }},ref=${{ github.ref_name }}"
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: checks
name: release-checks

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main
# run on stable tags only
tags:
- alpha
- v1
workflow_dispatch:
workflow_call:

jobs:
unit-test:
test-with-influxdb:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Run unit tests
run: make test

- name: Run status-writer-action action locally
uses: ./.github/composite-actions/status-writer
uses: ./.github/composite-actions/status-writer-released
if: always()
with:
# select the backend to use
Expand All @@ -38,5 +32,5 @@ jobs:
influxdb_bucket: "${{ secrets.INFLUXDB_BUCKET }}"
# set the status and additional metadata tags
repository: "${{ github.repository }}"
status: ${{ job.status }}
status: "${{ job.status }}"
tags: "workflow=${{ github.workflow }},job=${{ github.job }},ref=${{ github.ref_name }}"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Write GitHub Action job status to a remote backend.
This project currently supports:

- [InfluxDB](https://www.influxdata.com/).
- [InfluxDB](https://www.influxdata.com/)

## Prerequisites

Expand All @@ -21,7 +21,7 @@ Add the following step to your GitHub Action workflows for all jobs that you wou
```yaml
- name: Push job status and other metadata to a remote backend
# always run this step, even if previous steps fail
uses: dkoshkin/status-writer-action@v0.1.0
uses: dkoshkin/status-writer-action@alpha
# always run this step, even if previous steps fail
if: always()
with:
Expand All @@ -38,7 +38,7 @@ Add the following step to your GitHub Action workflows for all jobs that you wou
tags: "workflow=${{ github.workflow }},job=${{ github.job }},ref=${{ github.ref_name }}"
```
See sample workflows in [./.github-sample](./.github-sample)
See sample workflows in [.github/workflows/release-checks.yaml](.github/workflows/release-checks.yaml)
that use this GitHub Action as a [composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action).
There will be a sample workflow for each supported backend.
Expand Down
11 changes: 4 additions & 7 deletions hack/retag-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
set -euo pipefail
IFS=$'\n\t'

# This script re-tags a release branch after the binaries have been committed.
# It is intended to be run by the CI system after a successful release
# This script re-tags a release branch with a stable version after the binaries have been committed.
# It is intended to be run by the CI system after a successful release.

# Usage: retag-release.sh <version> <number of commits back from HEAD>
# Usage: retag-release.sh <version>
# Example: retag-release.sh v1

echo "Re-tagging ${1}"

# Use -f as the tag will already exist
git tag -a -m "${1}" "${1}" -f
git push origin "${1}" -f

# Tag on main so the next release can calculate release notes.
git tag -a -m "Will be used by the next release to calculate the release notes" "${1}-rn" HEAD~"${2}"
git push origin "${1}-rn"
9 changes: 6 additions & 3 deletions make/goreleaser.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ ifndef GORELEASER_CURRENT_TAG
export GORELEASER_CURRENT_TAG=$(GIT_TAG)
endif

# a stable tag to re-tag the release branches
STABLE_TAG="alpha"

.PHONY: build-snapshot
build-snapshot: ## Builds a snapshot with goreleaser
build-snapshot: install-tool.goreleaser install-tool.golang ; $(info $(M) building snapshot $*)
Expand All @@ -30,10 +33,10 @@ release: install-tool.goreleaser install-tool.golang ; $(info $(M) building rele
--parallelism=$(GORELEASER_PARALLELISM) \
--timeout=60m \
$(GORELEASER_FLAGS)
# force push the tag on the release branch after committing binaries
# force push a stable tag on the release branch after committing binaries
# GoReleaser after hooks are a paid feature, doing it here instead
# 4 is the number of commits (e.g. binaries) in the release branch
./hack/retag-release.sh $(GORELEASER_CURRENT_TAG) 4
./hack/retag-release.sh $(STABLE_TAG)
./hack/retag-release.sh "$(GORELEASER_CURRENT_TAG)-action"

.PHONY: release-snapshot
release-snapshot: ## Builds a snapshot release with goreleaser
Expand Down

0 comments on commit 45eea50

Please sign in to comment.