Release - Analysis #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release - Analysis | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to release (e.g., 1.123.0)' | |
required: true | |
type: string | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
paths: | |
- 'analysis/**' | |
- 'gh-pages/_posts/release/*ana_*.md' | |
env: | |
VERSION: "0.0.0" | |
jobs: | |
# Build artifacts | |
build: | |
if: | | |
(github.event_name == 'workflow_dispatch') || | |
(github.event_name == 'pull_request' && | |
github.event.pull_request.merged == true && | |
contains(github.event.pull_request.labels.*.name, 'release') && | |
startsWith(github.event.pull_request.head.ref, 'release/ana-')) | |
name: Build | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ env.VERSION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set version | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV | |
else | |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
echo "VERSION=${BRANCH_NAME#release/ana-}" >> $GITHUB_ENV | |
fi | |
- name: Create tag | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git tag "ana-${{ env.VERSION }}" | |
git push origin "ana-${{ env.VERSION }}" | |
- name: Build analysis | |
working-directory: ./analysis | |
run: | | |
chmod +x ./gradlew | |
./gradlew build | |
# Debug step to verify files | |
- name: List build artifacts | |
run: | | |
echo "Contents of analysis/build/distributions:" | |
ls -la analysis/build/distributions/ | |
echo "Found archives:" | |
find analysis/build/distributions -name "*.zip" -o -name "*.tar" | |
# Upload build artifacts for other jobs | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: analysis/build/distributions | |
# Create GitHub Release | |
create_release: | |
needs: build | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: analysis/build/distributions | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Create Release | |
run: | | |
# Debug: List files | |
echo "Contents of distributions directory:" | |
ls -la analysis/build/distributions/ | |
CHANGELOG_CONTENT=$(bun script/version-manager.ts extract-changelog analysis ${{ needs.build.outputs.version }}) | |
gh release create "ana-${{ needs.build.outputs.version }}" \ | |
--title "Analysis release ${{ needs.build.outputs.version }}" \ | |
--notes "$CHANGELOG_CONTENT" \ | |
analysis/build/distributions/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Publish to npm | |
publish_npm: | |
needs: build | |
name: Publish to npm | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: analysis/build/distributions | |
- name: Publish package | |
working-directory: analysis/node-wrapper | |
run: | | |
npm version ${{ needs.build.outputs.version }} --no-git-tag-version --allow-same-version | |
npm publish --tag latest --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# Publish to Docker Hub | |
publish_docker: | |
needs: build | |
name: Publish to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Pull and retag Docker image | |
run: | | |
docker pull codecharta/codecharta-analysis:staging | |
docker tag codecharta/codecharta-analysis:staging codecharta/codecharta-analysis:latest | |
docker tag codecharta/codecharta-analysis:staging codecharta/codecharta-analysis:${{ needs.build.outputs.version }} | |
docker push codecharta/codecharta-analysis:latest | |
docker push codecharta/codecharta-analysis:${{ needs.build.outputs.version }} |