Skip to content

migration self-update version #25

migration self-update version

migration self-update version #25

Workflow file for this run

---
name: Release
on:
push:
tags:
- '*.*.*'
permissions:
contents: write
packages: write
env:
GO_VERSION: '1.25.5'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Get version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected version: $VERSION"
if [ -z "$VERSION" ]; then
echo "Error: VERSION is empty"
exit 1
fi
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run tests
run: make test
- name: Run linter
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: --timeout=5m
continue-on-error: true
- name: Build release artifacts
env:
VERSION: ${{ env.VERSION }}
run: |
make VERSION="${VERSION}" release
ls -la dist/
- name: Verify release outputs
env:
VERSION: ${{ env.VERSION }}
run: |
set -e
expected_files=(
"dist/construct-darwin-arm64"
"dist/construct-darwin-amd64"
"dist/construct-linux-amd64"
"dist/construct-linux-arm64"
"dist/construct-darwin-arm64-${VERSION}.tar.gz"
"dist/construct-darwin-amd64-${VERSION}.tar.gz"
"dist/construct-linux-amd64-${VERSION}.tar.gz"
"dist/construct-linux-arm64-${VERSION}.tar.gz"
"dist/checksums.txt"
)
for file in "${expected_files[@]}"; do
if [ -f "${file}" ]; then
size=$(stat -c%s "${file}")
echo "✅ ${file} (size: ${size} bytes)"
else
echo "❌ Missing expected artifact: ${file}"
missing="yes"
fi
done
if [ "${missing:-no}" = "yes" ]; then
echo "One or more release artifacts are missing."
exit 1
fi
echo "All release artifacts verified."
- name: Show checksums
run: cat dist/checksums.txt
- name: Create Release Notes
env:
VERSION: ${{ env.VERSION }}
run: |
release_date=""
if [ -f CHANGELOG.md ]; then
release_date=$(awk -v ver="$VERSION" '
$0 ~ "^## \\["ver"\\] - " {
match($0, /^## \[[^]]+\] - (.+)$/, parts)
if (parts[1] != "") {
print parts[1]
}
exit
}' CHANGELOG.md)
fi
if [ -n "$release_date" ]; then
release_title="The Construct CLI $VERSION - $release_date"
else
release_title="The Construct CLI $VERSION"
fi
echo "RELEASE_TITLE=$release_title" >> "$GITHUB_ENV"
cat > release_notes.md << 'EOF'
## Release Notes
EOF
if [ -f CHANGELOG.md ]; then
awk -v ver="$VERSION" '
$0 ~ "^## \\["ver"\\] - " {found=1; next}
found && $0 ~ "^## \\[" {exit}
found {print}
' CHANGELOG.md | sed '1{/^$/d;}' >> release_notes.md
else
echo "- See commit history for details." >> release_notes.md
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: ${{ env.RELEASE_TITLE }}
body_path: release_notes.md
draft: false
prerelease: false
files: |
dist/construct-darwin-arm64-${{ env.VERSION }}.tar.gz
dist/construct-darwin-amd64-${{ env.VERSION }}.tar.gz
dist/construct-linux-amd64-${{ env.VERSION }}.tar.gz
dist/construct-linux-arm64-${{ env.VERSION }}.tar.gz
dist/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update VERSION file
env:
VERSION: ${{ env.VERSION }}
run: |
CURRENT_VERSION=""
if [ -f VERSION ]; then
CURRENT_VERSION=$(tr -d '[:space:]' < VERSION)
echo "Current VERSION file contains: ${CURRENT_VERSION}"
else
echo "VERSION file not found; it will be created."
fi
if [ "$CURRENT_VERSION" = "$VERSION" ]; then
echo "VERSION already matches ${VERSION}; skipping bump."
exit 0
fi
echo "$VERSION" > VERSION
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION
git commit -m "chore: update VERSION to $VERSION" || echo "No changes to commit"
git push origin HEAD:main || echo "Failed to push VERSION file update"
- name: Notify completion
run: |
echo "✅ Release ${{ env.VERSION }} created successfully!"
echo "📦 Assets uploaded for Linux and macOS (amd64/arm64)"