Release Traceway #7
This file contains hidden or 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 Traceway | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release version (X.Y.Z, no leading v)" | |
| required: true | |
| type: string | |
| change_1: | |
| description: "Changelog item 1 (optional)" | |
| required: false | |
| type: string | |
| change_2: | |
| description: "Changelog item 2 (optional)" | |
| required: false | |
| type: string | |
| change_3: | |
| description: "Changelog item 3 (optional)" | |
| required: false | |
| type: string | |
| change_4: | |
| description: "Changelog item 4 (optional)" | |
| required: false | |
| type: string | |
| change_5: | |
| description: "Changelog item 5 (optional)" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate version format | |
| run: | | |
| if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Error: version must be in X.Y.Z format (got '${{ inputs.version }}')" | |
| exit 1 | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check tag does not already exist | |
| run: | | |
| TAG="backend/v${{ inputs.version }}" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Error: tag $TAG already exists" | |
| exit 1 | |
| fi | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "latest" | |
| cache: "npm" | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Bump frontend version | |
| working-directory: frontend | |
| run: npm version "${{ inputs.version }}" --no-git-tag-version | |
| - name: Commit version bump | |
| run: | | |
| git add frontend/package.json frontend/package-lock.json | |
| git commit -m "v to ${{ inputs.version }}" | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Build frontend | |
| working-directory: frontend | |
| run: npm run build | |
| - name: Bundle frontend into backend | |
| run: | | |
| rm -rf backend/static/frontend | |
| mkdir -p backend/static/frontend | |
| cp -r frontend/build/. backend/static/frontend/ | |
| - name: Generate blog post | |
| env: | |
| C1: ${{ inputs.change_1 }} | |
| C2: ${{ inputs.change_2 }} | |
| C3: ${{ inputs.change_3 }} | |
| C4: ${{ inputs.change_4 }} | |
| C5: ${{ inputs.change_5 }} | |
| run: | | |
| mkdir -p website/content/blog | |
| POST="website/content/blog/v${{ inputs.version }}.mdx" | |
| { | |
| echo "---" | |
| echo "title: \"Backend v${{ inputs.version }}\"" | |
| echo "date: \"$(date -u +%Y-%m-%d)\"" | |
| echo "version: \"${{ inputs.version }}\"" | |
| echo "---" | |
| echo "" | |
| for C in "$C1" "$C2" "$C3" "$C4" "$C5"; do | |
| if [ -n "$C" ]; then | |
| echo "- $C" | |
| fi | |
| done | |
| } > "$POST" | |
| echo "Generated $POST:" | |
| cat "$POST" | |
| - name: Commit release | |
| run: | | |
| git add backend/static/frontend/ website/content/blog/ | |
| git add -A backend/ | |
| git commit -m "release: backend v${{ inputs.version }}" | |
| - name: Tag release | |
| run: git tag "backend/v${{ inputs.version }}" | |
| - name: Push branch and tag | |
| run: | | |
| git push origin HEAD:${{ github.ref_name }} | |
| git push origin "backend/v${{ inputs.version }}" | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| C1: ${{ inputs.change_1 }} | |
| C2: ${{ inputs.change_2 }} | |
| C3: ${{ inputs.change_3 }} | |
| C4: ${{ inputs.change_4 }} | |
| C5: ${{ inputs.change_5 }} | |
| run: | | |
| NOTES="" | |
| for C in "$C1" "$C2" "$C3" "$C4" "$C5"; do | |
| if [ -n "$C" ]; then | |
| NOTES="${NOTES}- ${C}"$'\n' | |
| fi | |
| done | |
| if [ -z "$NOTES" ]; then | |
| NOTES="Backend v${{ inputs.version }}" | |
| fi | |
| gh release create "backend/v${{ inputs.version }}" \ | |
| --title "Backend v${{ inputs.version }}" \ | |
| --notes "$NOTES" | |
| - name: Trigger website + docs deploys | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh workflow run release-website.yml --ref "${{ github.ref_name }}" | |
| gh workflow run release-docs.yml --ref "${{ github.ref_name }}" | |
| - name: Summary | |
| run: | | |
| echo "Released backend/v${{ inputs.version }}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "Users can now: \`go get github.com/tracewayapp/traceway/backend@v${{ inputs.version }}\`" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "Website and docs deploys will run automatically on release publish." >> "$GITHUB_STEP_SUMMARY" |