ci: use runner publish npmrc for Gitea E2E
Some checks failed
Gitea Runner E2E Publish / publish (push) Failing after 13s
Some checks failed
Gitea Runner E2E Publish / publish (push) Failing after 13s
This commit is contained in:
parent
96569e7d17
commit
7f16d8e61b
@ -9,7 +9,7 @@ jobs:
|
|||||||
runs-on: [ubuntu-latest, bytelyst, hostinger]
|
runs-on: [ubuntu-latest, bytelyst, hostinger]
|
||||||
container:
|
container:
|
||||||
image: node:20-bookworm
|
image: node:20-bookworm
|
||||||
options: -v /home/gitea-runner/.gitea_npm_token:/run/secrets/gitea_npm_token:ro
|
options: -v /home/gitea-runner/.gitea_publish_npmrc:/run/secrets/gitea_publish_npmrc:ro
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -22,37 +22,27 @@ jobs:
|
|||||||
- name: Set test version
|
- name: Set test version
|
||||||
working-directory: packages/_runner-e2e-test
|
working-directory: packages/_runner-e2e-test
|
||||||
run: |
|
run: |
|
||||||
VERSION="0.0.1-e2e.1"
|
VERSION="0.0.1-e2e.${GITHUB_RUN_ID:-$(date +%s)}"
|
||||||
echo "TEST_VERSION=$VERSION" >> "$GITHUB_ENV"
|
echo "TEST_VERSION=$VERSION" >> "$GITHUB_ENV"
|
||||||
npm version "$VERSION" --no-git-tag-version --allow-same-version
|
npm version "$VERSION" --no-git-tag-version --allow-same-version
|
||||||
node -p "require('./package.json').version"
|
node -p "require('./package.json').version"
|
||||||
- name: Configure registry .npmrc
|
- name: Configure registry .npmrc
|
||||||
working-directory: packages/_runner-e2e-test
|
working-directory: packages/_runner-e2e-test
|
||||||
run: |
|
run: |
|
||||||
TOKEN=$(tr -d '\n' < /run/secrets/gitea_npm_token)
|
cp /run/secrets/gitea_publish_npmrc .npmrc
|
||||||
cat > .npmrc <<NPMRC
|
sed -E 's|(:_auth=).*|\1***|; s|(:_authToken=).*|\1***|' .npmrc
|
||||||
@bytelyst:registry=https://gitea.bytelyst.com/api/packages/bytelyst/npm/
|
|
||||||
//gitea.bytelyst.com/api/packages/bytelyst/npm/:_authToken=$TOKEN
|
|
||||||
NPMRC
|
|
||||||
sed 's|_authToken=.*|_authToken=***|' .npmrc
|
|
||||||
- name: Publish to Hostinger Gitea
|
- name: Publish to Hostinger Gitea
|
||||||
working-directory: packages/_runner-e2e-test
|
working-directory: packages/_runner-e2e-test
|
||||||
run: pnpm publish --no-git-checks --registry https://gitea.bytelyst.com/api/packages/bytelyst/npm/
|
run: pnpm publish --no-git-checks --registry https://gitea.bytelyst.com/api/packages/bytelyst/npm/
|
||||||
- name: Verify package returned by Gitea
|
- name: Verify package returned by Gitea
|
||||||
|
working-directory: packages/_runner-e2e-test
|
||||||
run: |
|
run: |
|
||||||
TOKEN=$(tr -d '\n' < /run/secrets/gitea_npm_token)
|
npm view "@bytelyst/_runner-e2e-test@$TEST_VERSION" version --registry https://gitea.bytelyst.com/api/packages/bytelyst/npm/ | grep -qx "$TEST_VERSION"
|
||||||
RESP=$(curl -fsS -H "Authorization: token $TOKEN" "https://gitea.bytelyst.com/api/packages/bytelyst/npm/@bytelyst%2F_runner-e2e-test")
|
|
||||||
printf '%s' "$RESP" | python3 -c 'import json,sys; data=json.load(sys.stdin); print("package:", data.get("name")); print("versions:", ",".join(sorted(data.get("versions", {}).keys())))'
|
|
||||||
echo "$RESP" | grep -q "\"$TEST_VERSION\"" || { echo "FAIL: version missing from Gitea"; exit 1; }
|
|
||||||
echo "PASS: version in Gitea"
|
echo "PASS: version in Gitea"
|
||||||
- name: Verify pnpm install and require works
|
- name: Verify pnpm install and require works
|
||||||
run: |
|
run: |
|
||||||
TOKEN=$(tr -d '\n' < /run/secrets/gitea_npm_token)
|
|
||||||
mkdir -p /tmp/runner-e2e-consumer && cd /tmp/runner-e2e-consumer
|
mkdir -p /tmp/runner-e2e-consumer && cd /tmp/runner-e2e-consumer
|
||||||
cat > .npmrc <<NPMRC
|
cp /run/secrets/gitea_publish_npmrc .npmrc
|
||||||
@bytelyst:registry=https://gitea.bytelyst.com/api/packages/bytelyst/npm/
|
|
||||||
//gitea.bytelyst.com/api/packages/bytelyst/npm/:_authToken=$TOKEN
|
|
||||||
NPMRC
|
|
||||||
cat > package.json <<JSON
|
cat > package.json <<JSON
|
||||||
{ "name": "consumer", "version": "1.0.0", "dependencies": { "@bytelyst/_runner-e2e-test": "$TEST_VERSION" } }
|
{ "name": "consumer", "version": "1.0.0", "dependencies": { "@bytelyst/_runner-e2e-test": "$TEST_VERSION" } }
|
||||||
JSON
|
JSON
|
||||||
@ -62,12 +52,10 @@ jobs:
|
|||||||
- name: Verify local pack matches Gitea stored tarball shasum
|
- name: Verify local pack matches Gitea stored tarball shasum
|
||||||
working-directory: packages/_runner-e2e-test
|
working-directory: packages/_runner-e2e-test
|
||||||
run: |
|
run: |
|
||||||
TOKEN=$(tr -d '\n' < /run/secrets/gitea_npm_token)
|
|
||||||
pnpm pack --pack-destination /tmp
|
pnpm pack --pack-destination /tmp
|
||||||
TARBALL=$(ls /tmp/bytelyst-_runner-e2e-test-*.tgz)
|
TARBALL=$(ls /tmp/bytelyst-_runner-e2e-test-*.tgz)
|
||||||
LOCAL_SHA=$(sha1sum "$TARBALL" | awk '{print $1}')
|
LOCAL_SHA=$(sha1sum "$TARBALL" | awk '{print $1}')
|
||||||
RESP=$(curl -fsS -H "Authorization: token $TOKEN" "https://gitea.bytelyst.com/api/packages/bytelyst/npm/@bytelyst%2F_runner-e2e-test/$TEST_VERSION")
|
GITEA_SHA=$(npm view "@bytelyst/_runner-e2e-test@$TEST_VERSION" dist.shasum --registry https://gitea.bytelyst.com/api/packages/bytelyst/npm/)
|
||||||
GITEA_SHA=$(printf '%s' "$RESP" | python3 -c 'import json,sys; print(json.load(sys.stdin)["dist"]["shasum"])')
|
|
||||||
echo "LOCAL_SHA=$LOCAL_SHA"
|
echo "LOCAL_SHA=$LOCAL_SHA"
|
||||||
echo "GITEA_SHA=$GITEA_SHA"
|
echo "GITEA_SHA=$GITEA_SHA"
|
||||||
[ "$LOCAL_SHA" = "$GITEA_SHA" ] || { echo "FAIL: pnpm pack tarball does not match Gitea stored tarball"; exit 1; }
|
[ "$LOCAL_SHA" = "$GITEA_SHA" ] || { echo "FAIL: pnpm pack tarball does not match Gitea stored tarball"; exit 1; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user