autoupdate #37
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: autoupdate | |
on: | |
schedule: | |
- cron: 0 0 * * 5 | |
workflow_dispatch: | |
jobs: | |
autoupdate: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install Dependencies | |
run: cd api && npm ci | |
- name: Determine Version | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const year = new Date().getUTCFullYear().toString() | |
let month = new Date().getUTCMonth() + 1 | |
let day = new Date().getUTCDate() | |
if (month < 10) | |
month = '0' + month.toString() | |
if (day < 10) | |
day = '0' + day.toString() | |
const version = `1.${year + month + day}.0` | |
core.exportVariable('PACKAGE_VERSION', version) | |
core.exportVariable('VERSION', '@hetzner/api@' + version) | |
- name: Set Package Version | |
run: cd api && npm version $PACKAGE_VERSION | |
- name: Build Package | |
run: cd api && npm run build | |
- name: Publish Package | |
uses: JS-DevTools/npm-publish@v3 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
access: public | |
package: ./api | |
provenance: true | |
- name: Commit Changes | |
run: | | |
git config --global user.name "GitHub" | |
git config --global user.email "noreply@github.com" | |
git commit -am "refactor: autoupdate" | |
git push | |
- name: Create Release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release create $VERSION --title $VERSION |