Skip to content

chore: improve release workflow #60

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 8 commits into from
Jul 31, 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
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
Copy link
Member

Choose a reason for hiding this comment

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

nit: can remove else case and outdent below block due to exit 0

Copy link
Member Author

Choose a reason for hiding this comment

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

I also discovered that the gh release view is interactive and ensured it could run noninteractively.

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