Commit 575ed7d6 authored by Thomas Citharel's avatar Thomas Citharel
Browse files

Merge branch 'add-sha512sum-to-release-artifact' into 'master'

[CI] 🏗 Add SHA512 sum of the generated package in GitlabCI

See merge request framasoft/framadate/framadate!407
parents 31d454f1 db2ac8b2
Pipeline #2806 canceled with stage
in 43 seconds
...@@ -31,6 +31,12 @@ check-trad: ...@@ -31,6 +31,12 @@ check-trad:
- develop - develop
# Create artifacts on master # Create artifacts on master
# Create a ready-to-deploy package
# Create its sha512sum
# Put all that in the artifact for Gitlab pages
# Upload all the package and the sha512sum file to Gitlab
# Update the release description
# Add package and sha512sum file links to release assets
pages: pages:
stage: deploy stage: deploy
script: script:
...@@ -45,8 +51,12 @@ pages: ...@@ -45,8 +51,12 @@ pages:
- rm -rf framadate/.git - rm -rf framadate/.git
- export RELEASE_ZIP="framadate-${CI_COMMIT_TAG}.zip" - export RELEASE_ZIP="framadate-${CI_COMMIT_TAG}.zip"
- zip -r $RELEASE_ZIP framadate - zip -r $RELEASE_ZIP framadate
- sha512sum $RELEASE_ZIP > SHA512SUM
- mkdir .public - mkdir .public
- cp $RELEASE_ZIP .public/latest.zip - cp $RELEASE_ZIP .public/latest.zip
- cd .public
- sha512sum latest.zip > SHA512SUM
- cd ..
- mv .public public - mv .public public
- if [[ -z $GITLAB_API_TOKEN ]]; then exit; fi - if [[ -z $GITLAB_API_TOKEN ]]; then exit; fi
- export PROJECT_API_URL="https://framagit.org/api/v4/projects/${CI_PROJECT_ID}" - export PROJECT_API_URL="https://framagit.org/api/v4/projects/${CI_PROJECT_ID}"
...@@ -55,11 +65,14 @@ pages: ...@@ -55,11 +65,14 @@ pages:
- 'export HEADER="Private-Token: ${GITLAB_API_TOKEN}"' - 'export HEADER="Private-Token: ${GITLAB_API_TOKEN}"'
- export artifactUrl=$(curl -s --request POST --header "${HEADER}" --form "file=@${RELEASE_ZIP}" "${PROJECT_API_URL}/uploads" | jq -r .url) - export artifactUrl=$(curl -s --request POST --header "${HEADER}" --form "file=@${RELEASE_ZIP}" "${PROJECT_API_URL}/uploads" | jq -r .url)
- export artifactAbsoluteUrl="${CI_PROJECT_URL}${artifactUrl}" - export artifactAbsoluteUrl="${CI_PROJECT_URL}${artifactUrl}"
- export description=$(curl -s --header "${HEADER}" "${DESCRIPTION_URL}" | jq .release.description | sed -e 's@"@@g') - export sha512sumUrl=$(curl -s --request POST --header "${HEADER}" --form "file=@${SHA512SUM}" "${PROJECT_API_URL}/uploads" | jq -r .url)
- if [[ $description == 'null' ]]; then export METHOD="POST"; echo -e 'You can download the release zip here:'" [${RELEASE_ZIP}](${artifactAbsoluteUrl})" > /tmp/text; fi - export sha512sumAbsoluteUrl="${CI_PROJECT_URL}${sha512sumUrl}"
- if [[ $description != 'null' ]]; then export METHOD="PUT"; echo -e "${description}\n\n"'You can download the release zip here:'" [${RELEASE_ZIP}](${artifactAbsoluteUrl})" > /tmp/text; fi - export description=$(curl -s --header "${HEADER}" "${DESCRIPTION_URL}" | jq -r .release.description)
- if [[ $description == 'null' ]]; then export METHOD="POST"; echo -e 'You can download the release zip here:'" [${RELEASE_ZIP}](${artifactAbsoluteUrl}) ([SHA512SUM](${sha512sumAbsoluteUrl}))" > /tmp/text; fi
- if [[ $description != 'null' ]]; then export METHOD="PUT"; echo -e "${description}\n\n"'You can download the release zip here:'" [${RELEASE_ZIP}](${artifactAbsoluteUrl}) ([SHA512SUM](${sha512sumAbsoluteUrl}))" > /tmp/text; fi
- curl -s --request $METHOD --data-urlencode "description@/tmp/text" --header "${HEADER}" "${RELEASE_URL}" - curl -s --request $METHOD --data-urlencode "description@/tmp/text" --header "${HEADER}" "${RELEASE_URL}"
- curl -s --request POST --header "${HEADER}" --data name="${RELEASE_ZIP}" --data url="${artifactAbsoluteUrl}" "${PROJECT_API_URL}/releases/${CI_COMMIT_TAG}/assets/links" - curl -s --request POST --header "${HEADER}" --data name="${RELEASE_ZIP}" --data url="${artifactAbsoluteUrl}" "${PROJECT_API_URL}/releases/${CI_COMMIT_TAG}/assets/links"
- curl -s --request POST --header "${HEADER}" --data name="SHA512SUM" --data url="${sha512sumAbsoluteUrl}" "${PROJECT_API_URL}/releases/${CI_COMMIT_TAG}/assets/links"
artifacts: artifacts:
paths: paths:
- public - public
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment