Skip to content

chore: push scanning marker tag to remote (#8917) #5

chore: push scanning marker tag to remote (#8917)

chore: push scanning marker tag to remote (#8917) #5

Workflow file for this run

name: Create Draft Release
on:
push:
branches:
- main
- v1
permissions: read-all
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}-${{github.workflow}}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
check:
name: Check if release commit
runs-on: ubuntu-latest
if: "startsWith(github.event.head_commit.message, 'release: ')"
steps:
- name: Apply release-matching regexp to commit message
id: regex-match
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ github.event.head_commit.message }}
# Allow optional `v` prefix and GitHub PR reference suffix on first line only
# release: v1.2.3
# release: 1.2.3-beta.1
# release: v1.2.3-beta.1 (#9456)
regex: '^release: v?([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?)(\s+\(#[0-9]+\))?$'
flags: m
- name: Determine if applicable
id: check-commit-message
if: steps.regex-match.outputs.group1 != ''
run: |
echo "applicable=true" >> $GITHUB_OUTPUT
echo "This is a release commit: ${{ steps.regex-match.outputs.group1 }}"
outputs:
applicable: ${{ steps.check-commit-message.outputs.applicable }}
version: ${{ steps.regex-match.outputs.group1 }}
release:
name: Create Tag and Draft Release
needs: check
if: needs.check.outputs.applicable == 'true'
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Calculate Tag and Release names
run: |
echo TAG_NAME="v${{ needs.check.outputs.version }}" >> $GITHUB_ENV
echo RELEASE_NAME="v${{ needs.check.outputs.version }} Release" >> $GITHUB_ENV
- name: Create and push Tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -a ${{ env.TAG_NAME }} -m "${{ env.RELEASE_NAME }}"
git push origin ${{ env.TAG_NAME }}
- name: Install gsutil
run: |
curl -Lo $HOME/gsutil.tar.gz https://storage.googleapis.com/pub/gsutil.tar.gz
tar xfz $HOME/gsutil.tar.gz -C $HOME
echo "$HOME/gsutil" >> $GITHUB_PATH
- name: Download release artifacts
run: |
# Wait up to 60m for all artifacts to be available
retries=20
found=0
while [ $found -lt 10 -a $retries -gt 0 ]
do
sleep 3m
found=$(gsutil du gs://skaffold/releases/${{ env.TAG_NAME }}/ | wc -l)
retries=$((retries-1))
done
gsutil -m cp -r gs://skaffold/releases/${{ env.TAG_NAME }}/ $HOME
- name: Create Release
shell: bash
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
body=$(git log -p --follow -1 CHANGELOG.md | grep '^\+' | cut -c 2- | tail -n +2)
assets=()
for asset in $HOME/${{ env.TAG_NAME }}/*; do
assets+=("-a" "$asset")
done
bin/hub release create "${assets[@]}" -m "${{ env.RELEASE_NAME }}" -m "$body" --draft ${{ env.TAG_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}