Skip to content

Commit cebc951

Browse files
authored
chore: improve release workflow (#60)
* 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
1 parent c390e75 commit cebc951

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

.github/workflows/release.yaml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,23 @@ jobs:
6565
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/${version}.tgz gs://helm.coder.com/logstream-kube
6666
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/logstream-kube
6767
68-
- name: Create Release
69-
uses: actions/create-release@v1
70-
id: create_release
71-
env:
72-
GITHUB_TOKEN: ${{ github.token }}
73-
with:
74-
release_name: ${{ steps.version.outputs.version }}
75-
tag_name: ${{ github.ref }}
68+
- name: Create and upload release
69+
run: |
70+
set -euo pipefail
71+
version=${{ steps.version.outputs.version }}
72+
73+
# check if release already exists and match the version
74+
if [[ $(gh release view $version --json name -q '.name' | cat) == $version ]]; then
75+
echo "Release $version already exists"
76+
exit 0
77+
fi
7678
77-
- name: Upload Helm Release Asset
78-
uses: actions/upload-release-asset@v1
79+
echo "Creating release $version"
80+
# if version contains -rc, publish as a pre-release and don't set as latest
81+
if [[ $version == *-rc* ]]; then
82+
gh release create $version -t $version --generate-notes --prerelease --latest=false --verify-tag build/${version}.tgz#helm.tar.gz
83+
else
84+
gh release create $version -t $version --generate-notes --verify-tag build/${version}.tgz#helm.tar.gz
85+
fi
7986
env:
8087
GITHUB_TOKEN: ${{ github.token }}
81-
with:
82-
upload_url: ${{ steps.create_release.outputs.upload_url }}
83-
asset_path: build/${{ steps.version.outputs.version }}.tgz
84-
asset_name: helm.tar.gz
85-
asset_content_type: application/gzip

scripts/build.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ fi
3333
# Ensure the builder is bootstrapped and ready to use
3434
docker buildx inspect --bootstrap &>/dev/null
3535

36-
# Build
36+
# Build and push the image
3737
if [ "$CI" = "false" ]; then
3838
docker buildx build --platform linux/"$current" -t coder-logstream-kube --load .
3939
else
4040
VERSION=$(../scripts/version.sh)
4141
BASE=ghcr.io/coder/coder-logstream-kube
4242
IMAGE=$BASE:$VERSION
43-
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t "$IMAGE" -t $BASE:latest --push .
43+
# if version contains "rc" skip pushing to latest
44+
if [[ $VERSION == *"rc"* ]]; then
45+
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t "$IMAGE" --push .
46+
else
47+
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t "$IMAGE" -t $BASE:latest --push .
48+
fi
4449
fi

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy