From c1b3a3d49b466fdfae12bd4b9e3210674247373a Mon Sep 17 00:00:00 2001 From: Niclas Timle Date: Sat, 16 Nov 2024 12:41:07 +0100 Subject: [PATCH] Create release.yml --- .github/workflows/release.yml | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..cec6c88e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Angular Release Workflow + +on: + workflow_dispatch: # This allows manual triggering from the GitHub UI + inputs: + version: + description: 'Enter the version number (e.g., 1.2.0)' + required: false + default: 'auto' # Default version if user doesn't input anything + +jobs: + build_and_release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Install dependencies + run: | + npm ci + + - name: Get current version from package.json + id: get_version + run: | + VERSION=$(jq -r .version package.json) + echo "Current version is $VERSION" + echo "CURRENT_VERSION=$VERSION" >> $GITHUB_ENV + + - name: Ask for version if not provided + id: ask_version + run: | + if [ "${{ github.event.inputs.version }}" != "auto" ]; then + echo "Using provided version: ${{ github.event.inputs.version }}" + echo "NEW_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV + else + NEW_VERSION=$(npm version patch -m "Release version %s") + echo "Auto versioning: new version is $NEW_VERSION" + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + fi + + - name: Build Angular project + run: | + ng build --prod --configuration=production + + - name: Create Git tag with new version + run: | + git tag $NEW_VERSION + git push origin $NEW_VERSION + + - name: Upload production build to GitHub Releases + uses: softprops/action-gh-release@v1 + with: + files: ./dist/{your-project-name}/**/* # Adjust this path to match your dist folder + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}