update: 跳过格式错误的行 #24
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: Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Git | |
run: | | |
git config --global user.name "BarryZZJ" | |
git config --global user.email "[email protected]" | |
- name: Install GitHub CLI | |
run: | | |
VERSION=$(curl --silent https://api.github.com/repos/cli/cli/releases/latest | grep -oE "v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1) | |
curl -L "https://github.com/cli/cli/releases/download/$VERSION/gh_${VERSION#v}_linux_amd64.tar.gz" -o gh.tar.gz | |
tar xzvf gh.tar.gz | |
sudo mv gh_${VERSION#v}_linux_amd64/bin/gh /usr/local/bin/ | |
rm -rf gh_${VERSION#v}_linux_amd64 gh.tar.gz | |
- name: Generate tag and release description | |
run: | | |
export TZ=Asia/Shanghai | |
TIMESTAMP=$(date +%Y-%m-%d_%H%M%S) | |
echo "TIMESTAMP=${TIMESTAMP}" >> $GITHUB_ENV | |
echo "RELEASE_TAG=${TIMESTAMP}" >> $GITHUB_ENV | |
echo "RELEASE_DESC=Release created on ${TIMESTAMP}" >> $GITHUB_ENV | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git tag -a ${{ env.RELEASE_TAG }} -m "${{ env.RELEASE_DESC }}" | |
git push origin ${{ env.RELEASE_TAG }} | |
- name: Create release draft | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ env.RELEASE_TAG }} -t "${{ env.RELEASE_TAG }}" -n "${{ env.RELEASE_DESC }}" --draft=false --prerelease=false | |
- name: Pack repository into zip file | |
run: | | |
FILE_NAME=zhimengsub_$(basename $GITHUB_REPOSITORY)_${{ env.TIMESTAMP }} | |
echo "FILE_NAME=${FILE_NAME}" >> $GITHUB_ENV | |
zip -r $FILE_NAME.zip . -x "README.md" "LICENSE" ".gitignore" ".github/*" ".git/*" | |
- name: Upload zip file to release | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.FILE_NAME }} | |
path: ${{ env.FILE_NAME }}.zip | |
- name: Attach artifact to release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ env.RELEASE_TAG }} --clobber ${{ env.FILE_NAME }}.zip |