name: Release and Deploy Build on: workflow_dispatch: env: VERSION_MAJOR: '1' VERSION_MINOR: '1' jobs: build: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: https://gitea.com/actions/checkout@v4 with: fetch-depth: 0 fetch-tags: true - name: Use NodeJS v22.22.3 uses: https://gitea.com/actions/setup-node@v4 with: node-version: '22.22.3' registry-url: 'https://registry.npmjs.org' - name: Install Dependencies run: npm ci - name: Set Release Version id: version run: npm run version:place - name: Export Release Version id: release_version run: | package_version="$(node -p "require('./package.json').version")" echo "tag=${package_version}" >> "$GITEA_OUTPUT" - name: Run Build run: npm run build - name: Publish Library run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Create Gitea Release env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_REPOSITORY: ${{ gitea.repository }} GITEA_SERVER_URL: ${{ gitea.server_url }} GITEA_SHA: ${{ gitea.sha }} RELEASE_TAG: v${{ steps.release_version.outputs.tag }} run: | git fetch --force --tags previous_tag="$(git describe --tags --abbrev=0 "$GITEA_SHA^" 2>/dev/null || true)" if [ -n "$previous_tag" ]; then commit_messages="$(git log --reverse --format='- %s' "${previous_tag}..${GITEA_SHA}")" full_changelog="${GITEA_SERVER_URL}/${GITEA_REPOSITORY}/compare/${previous_tag}...${RELEASE_TAG}" else commit_messages="$(git log --reverse --format='- %s' "${GITEA_SHA}")" full_changelog="" fi if [ -z "$commit_messages" ]; then commit_messages='- No commits since the previous release' fi { echo '## Changes' echo printf '%s\n' "$commit_messages" echo if [ -n "$full_changelog" ]; then echo "**Full Changelog**: ${full_changelog}" fi } > release-notes.md node -e 'const fs = require("node:fs"); fs.writeFileSync("release.json", JSON.stringify({ tag_name: process.env.RELEASE_TAG, target_commitish: process.env.GITEA_SHA, name: process.env.RELEASE_TAG, body: fs.readFileSync("release-notes.md", "utf8") }))' api_url="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases" auth_header="Authorization: token ${GITEA_TOKEN}" if curl --fail --silent --header "$auth_header" --output current-release.json "${api_url}/tags/${RELEASE_TAG}"; then release_id="$(node -p 'require("./current-release.json").id')" curl --fail-with-body --header "$auth_header" --header 'Content-Type: application/json' --request PATCH --data-binary @release.json "${api_url}/${release_id}" else curl --fail-with-body --header "$auth_header" --header 'Content-Type: application/json' --request POST --data-binary @release.json "$api_url" fi