Release #219
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 | |
| on: | |
| workflow_run: | |
| workflows: [CI] | |
| types: [completed] | |
| jobs: | |
| release: | |
| if: > | |
| github.event.workflow_run.conclusion == 'success' && | |
| startsWith(github.event.workflow_run.head_branch, 'v') | |
| runs-on: ubuntu-latest | |
| environment: production | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: src/go.mod | |
| - run: make release | |
| - name: Determine version | |
| id: version | |
| run: | | |
| TAG="${{ github.event.workflow_run.head_branch }}" | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| echo "version=${TAG#v}" >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: ${{ steps.version.outputs.tag }} | |
| body: | | |
| See [CHANGELOG.md](https://github.com/factorly-dev/factorly/blob/${{ steps.version.outputs.tag }}/CHANGELOG.md) for details. | |
| make_latest: true | |
| files: | | |
| build/factorly-${{ steps.version.outputs.version }}-linux-amd64 | |
| build/factorly-${{ steps.version.outputs.version }}-linux-arm64 | |
| build/factorly-${{ steps.version.outputs.version }}-darwin-amd64 | |
| build/factorly-${{ steps.version.outputs.version }}-darwin-arm64 | |
| build/factorly-${{ steps.version.outputs.version }}-windows-amd64.exe | |
| build/checksums.txt | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Publish to npm | |
| working-directory: npm | |
| run: | | |
| CURRENT=$(node -p "require('./package.json').version") | |
| PUBLISHED=$(npm view factorly version 2>/dev/null || echo "none") | |
| if [ "$CURRENT" = "$PUBLISHED" ]; then | |
| echo "npm factorly@$CURRENT already published, skipping" | |
| else | |
| npm publish | |
| fi | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Publish to PyPI | |
| working-directory: pip | |
| run: | | |
| pip install build twine | |
| CURRENT=$(python -c "import re; print(re.search(r'version = \"(.+?)\"', open('pyproject.toml').read()).group(1))") | |
| PUBLISHED=$(pip index versions factorly 2>/dev/null | grep -oP 'factorly \(\K[^)]+' || echo "none") | |
| if [ "$CURRENT" = "$PUBLISHED" ]; then | |
| echo "PyPI factorly@$CURRENT already published, skipping" | |
| else | |
| python -m build | |
| twine upload dist/* | |
| fi | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| - name: Update Homebrew tap | |
| # Skip when BREW_TAP_TOKEN isn't configured yet — keeps existing | |
| # releases from breaking before the tap repo is set up. The | |
| # secret name is checked indirectly: GitHub Actions exposes | |
| # secrets only via the secrets context; the script itself | |
| # decides whether it has enough config to proceed. | |
| env: | |
| BREW_TAP_TOKEN: ${{ secrets.BREW_TAP_TOKEN }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| if [ -z "$BREW_TAP_TOKEN" ]; then | |
| echo "BREW_TAP_TOKEN not set, skipping Homebrew tap update" | |
| exit 0 | |
| fi | |
| ./brew/update-tap.sh |