name: release on: push: tags: - "v[0-9]+\\.[0-9]+\\.[0-9]+" workflow_call: inputs: tag: required: false type: string jobs: create_release: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ inputs.tag || github.ref }} - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci - name: Build TypeScript code run: npm run build - name: version id: version run: | REPOSITORY=$(echo ${{ github.event.repository.name }}) echo "repository=$REPOSITORY" >> "$GITHUB_OUTPUT" INPUT_TAG="${{ inputs.tag }}" if [ -n "$INPUT_TAG" ]; then VERSION="$INPUT_TAG" else VERSION=$(basename ${{ github.ref }}) fi echo "version=$VERSION" >> "$GITHUB_OUTPUT" VERSION_STRING=$(echo $VERSION | sed -e "s#\.#_#g") echo "version_string=$VERSION_STRING" >> "$GITHUB_OUTPUT" - name: Zip output id: create_zip run: | ARCHIVE_BASENAME=$(echo ${{steps.version.outputs.repository}}-${{steps.version.outputs.version_string}}) ARCHIVE_FILENAME=$(echo $ARCHIVE_BASENAME.zip) echo "filename=$ARCHIVE_FILENAME" >> "$GITHUB_OUTPUT" mkdir $ARCHIVE_BASENAME rsync -av ./* $ARCHIVE_BASENAME --exclude $ARCHIVE_BASENAME zip -r $ARCHIVE_FILENAME $ARCHIVE_BASENAME -x ".git" - name: Create Release id: create-release uses: softprops/action-gh-release@v1 with: name: Release ${{ steps.version.outputs.version }} tag_name: ${{ steps.version.outputs.version }} draft: true files: | ${{ steps.create_zip.outputs.filename}}