Skip to content

ci: fix version script and update release.yaml #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ jobs:
name: Build and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-tags: true

- name: Echo Go Cache Paths
id: go-cache-paths
Expand All @@ -44,11 +46,18 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push
- name: Get version
id: get-version
env:
ENVBUILDER_RELEASE: "t"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: the updated script will emit -dev versions unless this is explicitly set. In this case it will validate that the version is an annotated tag.

run: |
VERSION=$(./scripts/version.sh)
BASE=ghcr.io/coder/envbuilder
echo "ENVBUILDER_VERSION=$(./scripts.version.sh)" >> $GITHUB_OUTPUT

- name: Build and Push
env:
VERSION: "${{ steps.get-version.outputs.ENVBUILDER_VERSION }}"
BASE: "ghcr.io/coder/envbuilder"
run: |
./scripts/build.sh \
--arch=amd64 \
--arch=arm64 \
Expand Down
6 changes: 6 additions & 0 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ cdroot() {
log() {
echo "$*" 1>&2
}

# error prints an error message and returns an error exit code.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: missed copy-pasta

error() {
log "ERROR: $*"
exit 1
}
12 changes: 2 additions & 10 deletions scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,17 @@ if [[ "${ENVBUILDER_RELEASE:-}" == *t* ]]; then
# $last_tag will equal `git describe --always` if we currently have the tag
# checked out.
if [[ "${last_tag}" != "$(git describe --always)" ]]; then
# make won't exit on $(shell cmd) failures, so we have to kill it :(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: I don't think we need this given how we're building

if [[ "$(ps -o comm= "${PPID}" || true)" == *make* ]]; then
log "ERROR: version.sh: the current commit is not tagged with an annotated tag"
kill "${PPID}" || true
exit 1
fi

error "version.sh: the current commit is not tagged with an annotated tag"
fi
else
rev=$(git rev-parse --short HEAD)
version="0.0.0+dev-${rev}"
rev=$(git log -1 --format='%h' HEAD)
version+="+dev-${rev}"
# If the git repo has uncommitted changes, mark the version string as 'dirty'.
dirty_files=$(git ls-files --other --modified --exclude-standard)
if [[ -n "${dirty_files}" ]]; then
version+="-dirty"
fi
fi


# Remove the "v" prefix.
echo "${version#v}"