-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (94 loc) · 3.58 KB
/
Copy pathrelease.yml
File metadata and controls
105 lines (94 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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