Skip to content

chore: Upgrade vendored typescript-go to df62f5db69a2 #43

chore: Upgrade vendored typescript-go to df62f5db69a2

chore: Upgrade vendored typescript-go to df62f5db69a2 #43

Workflow file for this run

name: Push ~ post merge phase
on:
push:
branches: [ "master" ]
jobs:
check-pr-labels:
name: Check PR Labels
runs-on:
group: infra1-runners-arc
labels: runners-small
permissions:
contents: read
pull-requests: read
outputs:
skip_publish: ${{ steps.check_labels.outputs.skip_publish }}
steps:
- name: Get PR number and check labels
id: check_labels
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Find PR associated with this commit
const commit_sha = context.sha;
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: commit_sha
});
let skipPublish = false;
if (prs.length > 0) {
const pr = prs[0];
console.log(`Found PR #${pr.number} associated with commit ${commit_sha}`);
// Check if PR has "skip publish" label
const hasSkipPublishLabel = pr.labels.some(label => label.name === 'skip publish');
if (hasSkipPublishLabel) {
console.log('PR has "skip publish" label - publishing will be skipped');
skipPublish = true;
} else {
console.log('PR does not have "skip publish" label - proceeding with publish');
}
} else {
console.log('No PR found for this commit - proceeding with publish');
}
core.setOutput('skip_publish', skipPublish);
check-dependencies-changed:
runs-on:
group: infra1-runners-arc
labels: runners-small
permissions:
contents: read
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
changed:
- 'go.sum'
fossa-scan:
permissions:
id-token: write
contents: read
pull-requests: read
name: fossa-scan
needs: check-dependencies-changed
if: ${{ needs.check-dependencies-changed.outputs.changed == 'true' }}
uses: ./.github/workflows/rw-fossa.yml
with:
branch: 'master'
secrets: inherit
docker-build-and-publish:
name: Build and publish Docker image
runs-on:
group: infra1-runners-arc
labels: runners-small
needs: check-pr-labels
if: ${{ needs.check-pr-labels.outputs.skip_publish != 'true' }}
environment: public-release
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Read VERSION file
id: version
run: |
VERSION=$(cat VERSION)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Version to be published: ${VERSION}"
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: gooddatatiger
password: ${{ secrets.DOCKERHUB_WRITE_TOKEN }}
- name: Build and push Docker image with version tag
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
gooddata/gooddata-goodchanges:${{ steps.version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Install crane
uses: imjasonh/setup-crane@v0.3
- name: Tag image as latest
run: |
crane tag gooddata/gooddata-goodchanges:${{ steps.version.outputs.VERSION }} latest
- name: Build summary
run: |
echo "### Docker Image Published Successfully ✅" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** gooddata/gooddata-goodchanges" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo "- \`${{ steps.version.outputs.VERSION }}\`" >> $GITHUB_STEP_SUMMARY
echo "- \`latest\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Platforms:** linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
create-git-tag:
name: Create and push Git tag
runs-on:
group: infra1-runners-arc
labels: runners-small
needs: check-pr-labels
if: ${{ needs.check-pr-labels.outputs.skip_publish != 'true' }}
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Read VERSION file
id: version
run: |
VERSION=$(cat VERSION)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Git tag to be created: v${VERSION}"
- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Create and push Git tag
run: |
TAG_NAME="v${{ steps.version.outputs.VERSION }}"
# Check if tag already exists
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists. Skipping tag creation."
echo "### Git Tag Already Exists ⚠️" >> $GITHUB_STEP_SUMMARY
echo "Tag \`$TAG_NAME\` already exists for this version." >> $GITHUB_STEP_SUMMARY
else
echo "Creating tag $TAG_NAME for commit ${{ github.sha }}"
git tag -a "$TAG_NAME" -m "Release version ${{ steps.version.outputs.VERSION }}"
git push origin "$TAG_NAME"
echo "Successfully created and pushed tag: $TAG_NAME"
echo "### Git Tag Created Successfully ✅" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tag:** \`$TAG_NAME\`" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
fi
extract-changelog:
name: Extract and display changelog entry
runs-on:
group: infra1-runners-arc
labels: runners-small
permissions:
contents: read
outputs:
changelog_text: ${{ steps.output.outputs.changelog_text }}
changelog_json: ${{ steps.output.outputs.changelog_json }}
version: ${{ steps.version.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read VERSION file
id: version
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Extracting changelog for version: ${VERSION}"
- name: Extract changelog entry for current version
id: changelog
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
echo "Extracting changelog entry for version $VERSION..."
# Check if the version exists in the changelog
if ! grep -q "## \[$VERSION\]" CHANGELOG.md; then
echo "⚠️ Warning: CHANGELOG.md does not contain an entry for version $VERSION" >> $GITHUB_STEP_SUMMARY
exit 0
fi
# Extract the section for this version using awk
# This gets everything from the version header to the next version header or end of file
awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | head -n -1 > /tmp/version_section.txt
# If the above didn't capture anything (last version in file), try without the ending pattern
if [ ! -s /tmp/version_section.txt ]; then
awk "/## \[$VERSION\]/,EOF" CHANGELOG.md > /tmp/version_section.txt
fi
# Save the changelog content to a file for the summary
cat /tmp/version_section.txt > /tmp/changelog_content.txt
# Output the raw content for debugging
echo "Changelog content extracted:"
cat /tmp/changelog_content.txt
- name: Create changelog summary
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
echo "## 📋 Release Notes for v${VERSION}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f /tmp/changelog_content.txt ] && [ -s /tmp/changelog_content.txt ]; then
# Process and format the changelog content for the summary
while IFS= read -r line; do
# Skip empty lines at the beginning
if [[ -z "$line" ]] && [[ ! "$started" ]]; then
continue
fi
started=true
# Format headers and content
if [[ "$line" =~ ^##[[:space:]]\[.*\] ]]; then
# Version header - make it bold
echo "**${line}**" >> $GITHUB_STEP_SUMMARY
elif [[ "$line" =~ ^###[[:space:]] ]]; then
# Section headers (Added, Changed, etc.) - keep as is
echo "$line" >> $GITHUB_STEP_SUMMARY
else
# Regular content - preserve formatting
echo "$line" >> $GITHUB_STEP_SUMMARY
fi
done < /tmp/changelog_content.txt
else
echo "⚠️ No changelog entry found for version ${VERSION}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Consider adding a changelog entry in the following format:" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "## [${VERSION}] - $(date +%Y-%m-%d)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Added" >> $GITHUB_STEP_SUMMARY
echo "- New features" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Changed" >> $GITHUB_STEP_SUMMARY
echo "- Changes in existing functionality" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Fixed" >> $GITHUB_STEP_SUMMARY
echo "- Bug fixes" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi
- name: Output changelog for other jobs
id: output
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
if [ -f /tmp/changelog_content.txt ] && [ -s /tmp/changelog_content.txt ]; then
# Read the changelog content
CHANGELOG_TEXT=$(cat /tmp/changelog_content.txt)
# Create a JSON-safe version by escaping special characters
CHANGELOG_JSON=$(cat /tmp/changelog_content.txt | jq -Rs .)
# For multiline output in GitHub Actions, we use EOF delimiter
echo "changelog_text<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG_TEXT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Output JSON version
echo "changelog_json=${CHANGELOG_JSON}" >> $GITHUB_OUTPUT
echo "Changelog content has been set as output"
else
# Set empty values if no changelog found
echo "changelog_text=No changelog entry found for version ${VERSION}" >> $GITHUB_OUTPUT
echo "changelog_json=\"No changelog entry found for version ${VERSION}\"" >> $GITHUB_OUTPUT
echo "No changelog content to output"
fi
create-github-release:
name: Create GitHub Release
runs-on:
group: infra1-runners-arc
labels: runners-cxa-xlarge
needs: [ check-pr-labels, docker-build-and-publish, create-git-tag, extract-changelog ]
if: ${{ needs.check-pr-labels.outputs.skip_publish != 'true' }}
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read VERSION file
id: version
run: |
VERSION=$(cat VERSION)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Creating GitHub release for version: ${VERSION}"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Vendor typescript-go and tidy
run: |
bash vendor-tsgo.sh
go mod tidy
- name: Cross-compile binaries for all platforms
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
mkdir -p dist
TARGETS=(
# Linux
"linux/amd64"
"linux/arm64"
# macOS
"darwin/amd64"
"darwin/arm64"
# Windows
"windows/amd64"
"windows/arm64"
)
for target in "${TARGETS[@]}"; do
IFS='/' read -r os arch goarm <<< "$target"
ext=""
if [ "$os" = "windows" ]; then ext=".exe"; fi
if [ -n "$goarm" ]; then
name="goodchanges-${os}-${arch}v${goarm}${ext}"
echo "Building ${os}/${arch}v${goarm}..."
CGO_ENABLED=0 GOOS=$os GOARCH=arm GOARM=$goarm go build -ldflags="-s -w" -o "dist/${name}" .
else
name="goodchanges-${os}-${arch}${ext}"
echo "Building ${os}/${arch}..."
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags="-s -w" -o "dist/${name}" .
fi
# Package: .zip for windows, .tar.gz for everything else
cd dist
if [ "$os" = "windows" ]; then
zip "${name%.exe}.zip" "$name"
rm "$name"
else
tar czf "${name}.tar.gz" "$name"
rm "$name"
fi
cd ..
done
# Generate SHA-256 hashes for all archives
cd dist
for file in *; do
sha256sum "$file" > "${file}.sha256"
done
cd ..
echo "Built $(ls dist/ | grep -cv '\.sha256$') packages with SHA-256 hashes:"
ls -lh dist/
- name: Create Release Body
id: release_body
env:
CHANGELOG: ${{ needs.extract-changelog.outputs.changelog_text }}
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
# Create the release body with Docker information and changelog
cat << EOF > release_body.md
## Docker Image
The Docker image for this release has been published to DockerHub:
**Repository:** \`gooddata/gooddata-goodchanges\`
**Tags:**
- \`gooddata/gooddata-goodchanges:${VERSION}\`
- \`gooddata/gooddata-goodchanges:latest\`
### Pull Commands
\`\`\`bash
# Pull specific version
docker pull gooddata/gooddata-goodchanges:${VERSION}
# Pull latest
docker pull gooddata/gooddata-goodchanges:latest
\`\`\`
### Run Command
\`\`\`bash
docker run --rm gooddata/gooddata-goodchanges:${VERSION} [command]
\`\`\`
## Standalone Binaries
Download the binary for your platform from the assets below.
| Platform | Architecture | Asset |
|----------|-------------|-------|
| Linux | x86_64 | \`goodchanges-linux-amd64.tar.gz\` |
| Linux | ARM64 | \`goodchanges-linux-arm64.tar.gz\` |
| macOS | Intel | \`goodchanges-darwin-amd64.tar.gz\` |
| macOS | Apple Silicon | \`goodchanges-darwin-arm64.tar.gz\` |
| Windows | x86_64 | \`goodchanges-windows-amd64.zip\` |
| Windows | ARM64 | \`goodchanges-windows-arm64.zip\` |
<details>
<summary>All platforms</summary>
$(ls dist/ | sort | sed 's/^/- `/' | sed 's/$/`/')
</details>
### Install (Linux/macOS)
\`\`\`bash
# Example: download and install linux/amd64
curl -sL https://github.com/${{ github.repository }}/releases/download/v${VERSION}/goodchanges-linux-amd64.tar.gz | tar xz
chmod +x goodchanges-linux-amd64
sudo mv goodchanges-linux-amd64 /usr/local/bin/goodchanges
\`\`\`
## Changelog
${CHANGELOG}
## Build Information
- **Commit:** ${{ github.sha }}
- **Build Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
- **Workflow Run:** [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
EOF
echo "Release body created"
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.version.outputs.VERSION }}
name: Release v${{ steps.version.outputs.VERSION }}
bodyFile: release_body.md
artifacts: "dist/*"
draft: false
prerelease: false
makeLatest: true
generateReleaseNotes: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Release Summary
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
BINARY_COUNT=$(ls dist/ | wc -l)
echo "### 🎉 GitHub Release Created Successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Release:** v${VERSION}" >> $GITHUB_STEP_SUMMARY
echo "**Tag:** v${VERSION}" >> $GITHUB_STEP_SUMMARY
echo "**Binaries:** ${BINARY_COUNT} platform packages attached" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Docker Image:** \`gooddata/gooddata-goodchanges:${VERSION}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[View Release](https://github.com/${{ github.repository }}/releases/tag/v${VERSION})" >> $GITHUB_STEP_SUMMARY