Scheduled Release #44
This file contains hidden or 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: Scheduled Release | |
| on: | |
| schedule: | |
| # Run every Monday at 9:00 AM (UTC) | |
| - cron: '0 9 * * 1' | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Get package version | |
| id: package_version | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Generate timestamp | |
| id: timestamp | |
| run: echo "value=$(date '+%Y%m%d%H%M')" >> $GITHUB_OUTPUT | |
| - name: Set tag name | |
| id: tag | |
| run: echo "name=v${{ steps.package_version.outputs.version }}-${{ steps.timestamp.outputs.value }}" >> $GITHUB_OUTPUT | |
| - name: Create tag | |
| uses: actions/github-script@v5 | |
| with: | |
| script: | | |
| github.rest.git.createRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: 'refs/tags/${{ steps.tag.outputs.name }}', | |
| sha: context.sha | |
| }) | |
| - name: Create GitHub Release | |
| uses: actions/github-script@v5 | |
| with: | |
| script: | | |
| github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: '${{ steps.tag.outputs.name }}', | |
| name: '${{ steps.tag.outputs.name }}', | |
| body: 'Automated release created by GitHub Actions on ' + new Date().toISOString(), | |
| draft: false, | |
| prerelease: false | |
| }) | |
| - name: Trigger Publish Workflow | |
| uses: actions/github-script@v5 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'publish.yml', | |
| ref: 'main', | |
| inputs: { | |
| tag_name: '${{ steps.tag.outputs.name }}' | |
| } | |
| }) | |
| - name: Output created tag and release | |
| run: echo "Created tag and release ${{ steps.tag.outputs.name }} and triggered publish workflow" |