Skip to content

Commit

Permalink
chore: improve release workflow (#60)
Browse files Browse the repository at this point in the history
* chore: add prerelease flag to release.yaml and build.sh

* replace deprecated actions

* generate release notes

* specify tag_name

This should handle uploading asset to existing release when releases are created manually.

* refactor to use `gh release create`

* use asset name to match existing behaviour.

* makes sure we can run non-interactively in CI

* cleanup
  • Loading branch information
matifali authored Jul 31, 2024
1 parent c390e75 commit cebc951
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,23 @@ jobs:
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/${version}.tgz gs://helm.coder.com/logstream-kube
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/logstream-kube
- name: Create Release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ github.token }}
with:
release_name: ${{ steps.version.outputs.version }}
tag_name: ${{ github.ref }}
- name: Create and upload release
run: |
set -euo pipefail
version=${{ steps.version.outputs.version }}
# check if release already exists and match the version
if [[ $(gh release view $version --json name -q '.name' | cat) == $version ]]; then
echo "Release $version already exists"
exit 0
fi
- name: Upload Helm Release Asset
uses: actions/upload-release-asset@v1
echo "Creating release $version"
# if version contains -rc, publish as a pre-release and don't set as latest
if [[ $version == *-rc* ]]; then
gh release create $version -t $version --generate-notes --prerelease --latest=false --verify-tag build/${version}.tgz#helm.tar.gz
else
gh release create $version -t $version --generate-notes --verify-tag build/${version}.tgz#helm.tar.gz
fi
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/${{ steps.version.outputs.version }}.tgz
asset_name: helm.tar.gz
asset_content_type: application/gzip
9 changes: 7 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ fi
# Ensure the builder is bootstrapped and ready to use
docker buildx inspect --bootstrap &>/dev/null

# Build
# Build and push the image
if [ "$CI" = "false" ]; then
docker buildx build --platform linux/"$current" -t coder-logstream-kube --load .
else
VERSION=$(../scripts/version.sh)
BASE=ghcr.io/coder/coder-logstream-kube
IMAGE=$BASE:$VERSION
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t "$IMAGE" -t $BASE:latest --push .
# if version contains "rc" skip pushing to latest
if [[ $VERSION == *"rc"* ]]; then
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t "$IMAGE" --push .
else
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t "$IMAGE" -t $BASE:latest --push .
fi
fi

0 comments on commit cebc951

Please sign in to comment.