Debian Codegraph @

.github/workflows/publish-release.yml

raw
1 on:
2 push:
3 tags:
4 - "v*" # Push events to matching `v*` version srings. e.g. v1.0, v20.15.10
5
6 name: Create and Publish Release
7
8 jobs:
9 check-rust-ok:
10 runs-on: ubuntu-latest
11
12 steps:
13 - uses: actions/checkout@v3
14 with:
15 submodules: recursive
16 - name: Build
17 run: cargo build --verbose
18 - name: Check for lints
19 run: cargo clippy
20 - name: Run tests
21 run: |
22 cargo test --verbose
23
24 build:
25 name: Build Python distribution
26 runs-on: ubuntu-latest
27 permissions:
28 contents: write
29 steps:
30 - uses: actions/checkout@v2
31 with:
32 submodules: recursive
33 fetch-depth: 0
34 - name: Set up Python
35 uses: actions/setup-python@v2
36 with:
37 python-version: '3.x'
38
39 - name: Install release dependencies
40 run: |
41 python -m pip install --upgrade pip
42 pip install --upgrade setuptools wheel build
43
44 - name: Get release notes
45 id: release_notes
46 run: |
47 # By default, GH Actions checkout will only fetch a single commit.
48 # For us to extract the release notes, we need to fetch the tags
49 # and tag annotations as well.
50 # https://github.com/actions/checkout/issues/290
51 git fetch --tags --force
52 TAG_NAME=${GITHUB_REF/refs\/tags\//}
53 echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md"
54
55 - name: Create GitHub release
56 id: create_release
57 uses: actions/create-release@v1
58 env:
59 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 with:
61 tag_name: ${{ github.ref }}
62 release_name: ${{ github.ref }}
63 body_path: "${{ runner.temp }}/CHANGELOG.md"
64 draft: false
65 prerelease: false
66
67 - name: Build a binary wheel and a source tarball
68 run: python3 -m build
69 - name: Store the distribution packages
70 uses: actions/upload-artifact@v4
71 with:
72 name: python-package-distributions
73 path: dist/
74
75 publish-to-pypi:
76 name: >-
77 Publish Python 🐍 distribution 📦 to PyPI
78 if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
79 needs:
80 - build
81 runs-on: ubuntu-latest
82 environment:
83 name: pypi
84 url: https://pypi.org/p/axisregistry
85 permissions:
86 id-token: write # IMPORTANT: mandatory for trusted publishing
87 steps:
88 - name: Download all the dists
89 uses: actions/download-artifact@v4
90 with:
91 name: python-package-distributions
92 path: dist/
93 - name: Publish distribution 📦 to PyPI
94 uses: pypa/gh-action-pypi-publish@release/v1
95 with:
96 # repository-url: https://test.pypi.org/legacy/ # for testing purposes
97 verify-metadata: false # twine previously didn't verify metadata when uploading
98
99 publish-rust:
100 name: >-
101 Publish Rust 🦀 crate 📦 to crates.io
102 if: startsWith(github.ref, 'refs/tags/') # only publish to crates.io on tag pushes
103 needs:
104 - build
105 - check-rust-ok
106 runs-on: ubuntu-latest
107 steps:
108 - uses: actions/checkout@v3
109 with:
110 submodules: recursive
111 - name: Check tag version and Cargo.toml version are same
112 run: |
113 TAG_NAME=${GITHUB_REF/refs\/tags\//}
114 CARGO_TOML_VERSION=$(grep -E '^version\s*=' Cargo.toml | cut -d '"' -f 2)
115 if [ "$TAG_NAME" != "$CARGO_TOML_VERSION" ]; then
116 echo "Tag version ($TAG_NAME) and Cargo.toml version ($CARGO_TOML_VERSION) do not match."
117 exit 1
118 fi
119 - name: Publish crate 📦 to crates.io
120 run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
121
122 upstream-subtree-merge:
123 name: >-
124 Update google/fonts with a new release of axisregistry
125 if: startsWith(github.ref, 'refs/tags/') # only merge into upstream on tag pushes
126 needs:
127 - build
128 runs-on: ubuntu-latest
129 steps:
130 - name: Checkout google/fonts
131 uses: actions/checkout@v3
132 with:
133 repository: google/fonts
134 token: ${{ secrets.GOOGLE_FONTS_TOKEN }}
135 fetch-depth: 0
136
137 - name: Configure git
138 run: |
139 git config user.name "axisregistry-bot"
140 git config user.email "[email protected]"
141
142 - name: Create branch
143 id: branch
144 run: |
145 TAG_NAME="${GITHUB_REF#refs/tags/}"
146 BRANCH_NAME="axisregistry-release-${TAG_NAME}"
147 git checkout -b "${BRANCH_NAME}"
148 echo "branch_name=${BRANCH_NAME}" >> "$GITHUB_OUTPUT"
149
150 - name: Subtree pull from axisregistry main
151 run: |
152 git subtree pull \
153 --prefix=axisregistry \
154 https://github.com/googlefonts/axisregistry.git \
155 main
156
157 - name: Push branch to google/fonts
158 run: |
159 git push origin "${{ steps.branch.outputs.branch_name }}"
160
161 - name: Create Pull Request
162 env:
163 GH_TOKEN: ${{ secrets.GOOGLE_FONTS_TOKEN }}
164 run: |
165 TAG_NAME="${GITHUB_REF#refs/tags/}"
166 gh pr create \
167 --repo google/fonts \
168 --base main \
169 --head "${{ steps.branch.outputs.branch_name }}" \
170 --title "Update axisregistry to ${TAG_NAME}" \
171 --body "This PR updates the \`axisregistry\` subtree with the latest release ($TAG_NAME) from [googlefonts/axisregistry](https://github.com/googlefonts/axisregistry). **Important:** When merging, use the **\"Create a merge commit\"** button, **not** \"Squash and merge\", to preserve subtree history and avoid future merge conflicts."