0.0.1 #2
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 | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Extract version from commit message | |
id: ver | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
echo "Commit message: $COMMIT_MESSAGE" | |
if [[ $COMMIT_MESSAGE =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "version=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT | |
else | |
echo "exit no version x.x.x in the commit message" | |
exit 1 | |
fi | |
# Remove existing data.json file | |
- name: Remove data.json | |
run: rm -f data.json | |
# Get a list of all the files in the prompts folder | |
- name: Get list of prompts | |
run: ls prompts > prompts.txt | |
# Remove the file extension from each file name | |
- name: Remove file extensions | |
run: sed -i 's/\..*$//' prompts.txt | |
- name: Create data.json | |
run: | | |
# Add double quotes around each line | |
sed -i 's/^/"/' prompts.txt | |
sed -i 's/$/"/' prompts.txt | |
# Add comma at the end of each line except the last one | |
sed -i '$!s/$/,/' prompts.txt | |
# Create the JSON file | |
echo "{\"prompts\": [$(cat prompts.txt)]}" > data.json | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.ver.outputs.version }} | |
release_name: ${{ steps.ver.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Attach data.json | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: data.json | |
asset_name: data.json | |
asset_content_type: application/json | |
- name: Attach manifest.json | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: manifest.json | |
asset_name: manifest.json | |
asset_content_type: application/json |