Skip to content

Commit 45d8edf

Browse files
authored
Adhere to semver more closely (#426)
* Update versioning scheme; Use more WF variables * Add version to archive file names * Fix quotes * Change tagging strategy
1 parent f44c13e commit 45d8edf

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,40 @@ jobs:
5757
registry: ${{ env.CONTAINER_REGISTRY }}
5858
username: ${{ github.actor }}
5959
password: ${{ secrets.GITHUB_TOKEN }}
60-
- run: make install
61-
- run: make build docker BUILD_VERSION="v0.0.0 (master)" CONTAINER_TAG=latest
62-
if: startswith(github.ref, 'refs/heads/master')
63-
- run: make build docker BUILD_VERSION="v0.0.0 ($(echo $GITHUB_REF | sed -e 's/^refs\/pull\///'))" CONTAINER_TAG=dev
64-
if: startswith(github.ref, 'refs/pull/')
65-
- run: make build docker BUILD_VERSION="v$(echo $GITHUB_REF | sed -e 's/^refs\/tags\///')" CONTAINER_TAG="$(echo $GITHUB_REF | sed -e 's/^refs\/tags\///')"
66-
if: startswith(github.ref, 'refs/tags/')
67-
- run: make archive
60+
61+
- name: Install deps
62+
run: make install
63+
64+
- name: Set env vars (push)
65+
run: |
66+
echo "BUILD_VERSION=0.0.0-beta+commit.${{ github.sha }}" >> $GITHUB_ENV
67+
echo "CONTAINER_TAG=beta" >> $GITHUB_ENV
68+
if: github.event_name == 'push'
69+
- name: Set env vars (pr)
70+
run: |
71+
echo "BUILD_VERSION=0.0.0-pr${{ github.event.pull_request.number }}+commit.${{ github.sha }}" >> $GITHUB_ENV
72+
echo "CONTAINER_TAG=pr${{ github.event.pull_request.number }}" >> $GITHUB_ENV
73+
if: github.event_name == 'pull_request'
74+
- name: Set env vars (release)
75+
run: |
76+
echo "BUILD_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
77+
echo "CONTAINER_TAG=latest" >> $GITHUB_ENV
78+
if: github.event_name == 'release'
79+
80+
- name: Build
81+
run: make build docker archive
82+
83+
- name: Publish container image (release)
84+
run: make docker CONTAINER_TAG=${{ github.event.release.tag_name }}
85+
if: github.event_name == 'release'
86+
6887
- uses: actions/upload-artifact@v4
6988
with:
7089
name: artifacts
7190
path: |
7291
build/gomp-*
7392
- uses: softprops/action-gh-release@v2
74-
if: startsWith(github.ref, 'refs/tags/')
93+
if: github.event_name == 'release'
7594
with:
7695
files: |
7796
build/gomp-*

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
NPROCS = $(shell grep -c 'processor' /proc/cpuinfo)
22
MAKEFLAGS += -j$(NPROCS)
33

4-
BUILD_VERSION=
4+
BUILD_VERSION?=
5+
ARCHIVE_SUFFIX:=
6+
ifdef BUILD_VERSION
7+
ARCHIVE_SUFFIX:=-$(BUILD_VERSION)
8+
endif
59

610
BUILD_DIR=build
711
BUILD_LIN_AMD64_DIR=$(BUILD_DIR)/linux/amd64
@@ -184,13 +188,13 @@ endif
184188
# ---- ARCHIVE ----
185189

186190
.PHONY: archive
187-
archive: $(BUILD_DIR)/gomp-linux-amd64.tar.gz $(BUILD_DIR)/gomp-linux-arm.tar.gz $(BUILD_DIR)/gomp-linux-arm64.tar.gz $(BUILD_DIR)/gomp-windows-amd64.zip
191+
archive: $(BUILD_DIR)/gomp-linux-amd64$(ARCHIVE_SUFFIX).tar.gz $(BUILD_DIR)/gomp-linux-arm$(ARCHIVE_SUFFIX).tar.gz $(BUILD_DIR)/gomp-linux-arm64$(ARCHIVE_SUFFIX).tar.gz $(BUILD_DIR)/gomp-windows-amd64$(ARCHIVE_SUFFIX).zip
188192

189-
$(BUILD_DIR)/gomp-linux-amd64.tar.gz: $(BUILD_LIN_AMD64_DIR)
190-
$(BUILD_DIR)/gomp-linux-arm.tar.gz: $(BUILD_LIN_ARM_DIR)
191-
$(BUILD_DIR)/gomp-linux-arm64.tar.gz: $(BUILD_LIN_ARM64_DIR)
192-
$(BUILD_DIR)/gomp-linux-%.tar.gz:
193+
$(BUILD_DIR)/gomp-linux-amd64$(ARCHIVE_SUFFIX).tar.gz: $(BUILD_LIN_AMD64_DIR)
194+
$(BUILD_DIR)/gomp-linux-arm$(ARCHIVE_SUFFIX).tar.gz: $(BUILD_LIN_ARM_DIR)
195+
$(BUILD_DIR)/gomp-linux-arm64$(ARCHIVE_SUFFIX).tar.gz: $(BUILD_LIN_ARM64_DIR)
196+
$(BUILD_DIR)/gomp-linux-%$(ARCHIVE_SUFFIX).tar.gz:
193197
tar -C $< -zcf $@ .
194198

195-
$(BUILD_DIR)/gomp-windows-amd64.zip: $(BUILD_WIN_AMD64_DIR)
199+
$(BUILD_DIR)/gomp-windows-amd64$(ARCHIVE_SUFFIX).zip: $(BUILD_WIN_AMD64_DIR)
196200
cd $< && zip -rq ../../../$@ *

0 commit comments

Comments
 (0)