extract sha using filename #6
Workflow file for this run
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: ci | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 16.x | ||
- run: npm install | ||
- run: npm run test | ||
# run only on semantic version tag | ||
release: | ||
needs: test | ||
# if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.') | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
# # GITHUB_ENV operates like a .env file | ||
# - name: extract version | ||
# run: | | ||
# VERSION=${GITHUB_REF#refs/tags/} | ||
# CLEAN_VERSION=${VERSION#v} | ||
# echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
# echo "CLEAN_VERSION=$CLEAN_VERSION" >> $GITHUB_ENV | ||
- name: node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 16.x | ||
- name: npm install | ||
run: npm install | ||
- name: dist | ||
run: | | ||
mkdir -p dist | ||
- name: pack | ||
run: npx [email protected] pack tarballs | ||
- name: extract sha | ||
id: extract_sha | ||
run: | | ||
# list files in dist directory | ||
ls dist/ | ||
# extract version and SHA from the filename | ||
FILENAME=$(ls dist/ | grep 'dotenv-vault-v.*-linux-x64.tar.gz' | head -n 1) | ||
echo "extracted filename: $FILENAME" | ||
VERSION=$(echo $FILENAME | grep -oP '(?<=dotenv-vault-v)[0-9.]+(?=-)') | ||
SHA=$(echo $FILENAME | grep -oP '(?<=dotenv-vault-v[0-9.]+-)[^-]+(?=-linux-x64.tar.gz)') | ||
echo "Extracted version: $VERSION" | ||
echo "Extracted SHA: $SHA" | ||
# Set outputs | ||
echo "::set-output name=version::$VERSION" | ||
echo "::set-output name=sha::$SHA" | ||
- name: upload | ||
run: npx [email protected] upload tarballs | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
- name: promote | ||
run: | | ||
echo "${{ steps.upload }}" | ||
PROMOTE_VERSION=$(echo ${{ steps.extract_sha.outputs.version }}) | ||
PROMOTE_SHA=$(echo ${{ steps.extract_sha.outputs.sha }}) | ||
npx [email protected] promote --version "$PROMOTE_VERSION" --sha "$PROMOTE_SHA" | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |