Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ci: added referer to GOE post in release workflow #376

Merged
merged 4 commits into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 61 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
required: false

jobs:
pypi:
publishing:
strategy:
matrix:
node_version: ["latest"]
Expand Down Expand Up @@ -55,8 +55,66 @@ jobs:
with:
name: forge-gnome-extension
path: forge@jmmaranan.com.zip
# path: temp/

- name: Upload extension to Goe
shell: bash
env:
USERNAME: ${{ secrets.GOE_USERNAME }}
PASSWORD: ${{ secrets.GOE_PASSWORD }}
run: |
curl -i -X POST -H "Content-Type: multipart/form-data" -F "source=@forge@jmmaranan.com.zip" -F "tos_compliant=on" -F "shell_license_compliant=on" https://extensions.gnome.org/upload/
printf '::group::Getting CSRF Midleware Token for accounts/login form\n';
if test -z "${USERNAME:-}"; then printf 'Missing USERNAME from environment variable.\n::endgroup::\n'; exit 1; fi
if test -z "${PASSWORD:-}"; then printf 'Missing PASSWORD from environment variable\n::endgroup::\n'; exit 1; fi
curl 'https://extensions.gnome.org/accounts/login/' \
--junk-session-cookies \
-b 00-cookies-jar.txt -c 00-cookies-jar.txt \
--location --fail-with-body \
--no-progress-meter --verbose \
-o 01-get-accounts-login.html;

export CSRFMIDDLEWARETOKEN="$(grep --color=never 'csrfmiddlewaretoken' < 01-get-accounts-login.html | grep --only-matching --perl-regexp '(?<=value=.)([^\"]+)' | head -n 1)";
if test -z "${CSRFMIDDLEWARETOKEN:-}"; then printf 'Missing CSRFMIDDLEWARETOKEN from accounts/login form.\n::endgroup::\n'; exit 1; fi
printf '::endgroup::\n';

printf '::group::Authenticating in extensions.gnome.org\n';
if ! curl 'https://extensions.gnome.org/accounts/login/' \
-H 'origin: https://extensions.gnome.org' \
-H 'referer: https://extensions.gnome.org/accounts/login/' \
-H 'content-type: application/x-www-form-urlencoded' \
--data-urlencode 'next=' \
--data-urlencode "csrfmiddlewaretoken=${CSRFMIDDLEWARETOKEN}" \
--data-urlencode "username=${USERNAME}" \
--data-urlencode "password=${PASSWORD}" \
-b 00-cookies-jar.txt -c 00-cookies-jar.txt \
--location --fail-with-body \
--no-progress-meter --verbose \
-o 02-post-accounts-login.html;
then
printf 'Login failed with error: %s\n::endgroup::\n' "$?";
exit 2;
fi
printf '::endgroup::\n';

printf '::group::Getting CSRF Midleware Token for upload form\n';
curl 'https://extensions.gnome.org/upload/' \
-b 00-cookies-jar.txt -c 00-cookies-jar.txt \
--location --fail-with-body \
--no-progress-meter --verbose \
-o 03-get-upload.html;
export CSRFMIDDLEWARETOKEN="$(grep --color=never 'csrfmiddlewaretoken' < 03-get-upload.html | grep --only-matching --perl-regexp '(?<=value=.)([^\"]+)' | head -n 1)";
if test -z "${CSRFMIDDLEWARETOKEN:-}"; then printf 'Missing CSRFMIDDLEWARETOKEN from upload form.\n::endgroup::\n'; exit 3; fi
printf '::endgroup::\n';

printf '::group::Uploading extension zip\n';
curl 'https://extensions.gnome.org/upload/' \
-H 'origin: https://extensions.gnome.org' \
-H 'referer: https://extensions.gnome.org/upload/' \
-F "csrfmiddlewaretoken=${CSRFMIDDLEWARETOKEN}" \
-F 'tos_compliant=on' \
-F 'shell_license_compliant=on' \
-F 'source=@forge@jmmaranan.com.zip' \
-b 00-cookies-jar.txt -c 00-cookies-jar.txt \
--location --fail-with-body \
--no-progress-meter --verbose \
-o 04-post-upload.html;
printf '::endgroup::\n';