Fix delete old artifacts #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Merge PR | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
concurrency: | |
group: merge | |
cancel-in-progress: false | |
jobs: | |
merge: | |
name: Merge PR | |
runs-on: self-hosted-hoprnet-small | |
if: github.event.pull_request.merged == true | |
steps: | |
- name: Setup uhttp repository | |
id: setup | |
uses: hoprnet/uhttp-crypto/.github/actions/setup@main | |
with: | |
node-version: 20 | |
google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }} | |
- name: Unpublish PR commit versions | |
run: | | |
gcloud artifacts versions list --repository=npm --location=europe-west3 --project=hoprassociation --package=${{ vars.NPM_PACKAGE_NAME }} --format=json 2> /dev/null | jq -r ' .[] | select(.name | contains("-pr.${{ github.event.pull_request.number }}-")).name' | sed 's/.*versions\///g' > pr_commit_versions.txt | |
while read -r version; do | |
echo "Unpublishing commit version: $version" | |
gcloud artifacts versions delete --delete-tags --quiet --repository=npm --location=europe-west3 --project=hoprassociation --package ${{ vars.NPM_PACKAGE_NAME }} $version | |
done < pr_commit_versions.txt | |
- name: Publish alpha version | |
run: | | |
BUILD_DATE=$(date +%Y%m%d%H%M%S) | |
PR_VERSION=$(node -p "require('./package.json').version")-pr.${{ github.event.pull_request.number }} | |
jq --arg version "${PR_VERSION}-${BUILD_DATE}" '.version = $version' package.json > temp.json | |
mv temp.json package.json | |
yarn publish --tag next | |
jq --arg version "${PR_VERSION}" '.version = $version' package.json > temp.json | |
mv temp.json package.json | |
yarn publish --tag alpha | |
env: | |
NODE_AUTH_TOKEN: ${{ steps.setup.outputs.access_token }} |