Manually generate distribution archives (#1032)

Github has a habit of changing how the automatic source archives are generated (e.g. compression), which
changes their checksums, which then breaks users. Instead of risking that happening again, generate
the distribution archive as part of the release workflow and upload it to the release. The same mechanism,
`git export` is used, so the format and structure is the same as before.
diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/create_archive_and_notes.sh
similarity index 81%
rename from .github/workflows/workspace_snippet.sh
rename to .github/workflows/create_archive_and_notes.sh
index bfc0d8b..549af07 100755
--- a/.github/workflows/workspace_snippet.sh
+++ b/.github/workflows/create_archive_and_notes.sh
@@ -13,16 +13,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 set -o errexit -o nounset -o pipefail
 
 # Set by GH actions, see
 # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
 TAG=${GITHUB_REF_NAME}
+# A prefix is added to better match the GitHub generated archives.
 PREFIX="rules_python-${TAG}"
-SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')
+ARCHIVE="rules_python-$TAG.tar.gz"
+git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
+SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
 
-cat << EOF
+cat > release_notes.txt << EOF
 ## Using Bzlmod with Bazel 6
 
 Add to your \`MODULE.bazel\` file:
@@ -65,7 +67,7 @@
     name = "rules_python",
     sha256 = "${SHA}",
     strip_prefix = "${PREFIX}",
-    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz",
+    url = "https://github.com/bazelbuild/rules_python/releases/download/${TAG}/rules_python-${TAG}.tar.gz",
 )
 
 load("@rules_python//python:repositories.bzl", "py_repositories")
@@ -83,7 +85,7 @@
     name = "rules_python_gazelle_plugin",
     sha256 = "${SHA}",
     strip_prefix = "${PREFIX}/gazelle",
-    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz",
+    url = "https://github.com/bazelbuild/rules_python/releases/download/${TAG}/rules_python-${TAG}.tar.gz",
 )
 \`\`\`
 EOF
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5b1cde0..1e89fa8 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -26,11 +26,13 @@
     steps:
       - name: Checkout
         uses: actions/checkout@v2
-      - name: Prepare workspace snippet
-        run: .github/workflows/workspace_snippet.sh > release_notes.txt
+      - name: Create release archive and notes
+        run: .github/workflows/create_archive_and_notes.sh
       - name: Release
         uses: softprops/action-gh-release@v1
         with:
           # Use GH feature to populate the changelog automatically
           generate_release_notes: true
           body_path: release_notes.txt
+          fail_on_unmatched_files: true
+          files: rules_python-*.tar.gz