Move to ci #20
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: | |
# always run tests | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
- run: npm install | |
- run: npm run standard | |
- run: npm test | |
# run only on semantic version tag | |
release: | |
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.') | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
# 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@v1 | |
with: | |
node-version: 16.x | |
# https://news.ycombinator.com/item?id=32388964 | |
# https://github.com/procursusteam/ldid | |
# https://www.pulumi.com/blog/nodejs-binaries-with-pkg/ | |
# https://github.com/pulumi/pulumi-aws-static-website/blob/main/.github/workflows/release.yaml | |
- name: ldid for macos binary building | |
uses: MOZGIII/install-ldid-action@v1 | |
with: | |
tag: v2.1.5-procursus2 | |
- name: npm install | |
run: npm install | |
- name: pkg | |
run: | | |
echo "pkg-ing" | |
./node_modules/.bin/pkg . --no-bytecode --public-packages "*" --public --target node16-macos-x64 --output bin/darwin-amd64/git-dotenv | |
./node_modules/.bin/pkg . --no-bytecode --public-packages "*" --public --target node16-macos-arm64 --output bin/darwin-arm64/git-dotenv | |
./node_modules/.bin/pkg . --no-bytecode --public-packages "*" --public --target node16-linuxstatic-x64 --output bin/linux-amd64/git-dotenv | |
./node_modules/.bin/pkg . --no-bytecode --public-packages "*" --public --target node16-linuxstatic-arm64 --output bin/linux-arm64/git-dotenv | |
./node_modules/.bin/pkg . --no-bytecode --public-packages "*" --public --target node16-win-x64 --output bin/windows-amd64/git-dotenv.exe | |
echo "dist-ing" | |
mkdir -p dist | |
tar --gzip -cf ./dist/git-dotenv-${{ env.CLEAN_VERSION }}-darwin-amd64.tar.gz README.md -C bin/darwin-amd64/ . | |
tar --gzip -cf ./dist/git-dotenv-${{ env.CLEAN_VERSION }}-darwin-arm64.tar.gz README.md -C bin/darwin-arm64/ . | |
tar --gzip -cf ./dist/git-dotenv-${{ env.CLEAN_VERSION }}-linux-amd64.tar.gz README.md -C bin/linux-amd64/ . | |
tar --gzip -cf ./dist/git-dotenv-${{ env.CLEAN_VERSION }}-linux-arm64.tar.gz README.md -C bin/linux-arm64/ . | |
tar --gzip -cf ./dist/git-dotenv-${{ env.CLEAN_VERSION }}-windows-amd64.tar.gz README.md -C bin/windows-amd64/ . | |
- name: create release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
dist/*.tar.gz | |
- name: gen checksums | |
uses: wangzuo/action-release-checksums@v1 | |
homebrew: | |
needs: release | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
steps: | |
# https://github.com/Justintime50/homebrew-releaser | |
- name: homebrew releaser | |
uses: Justintime50/homebrew-releaser@v1 | |
with: | |
debug: false | |
homebrew_owner: dotenv-org | |
homebrew_tap: homebrew-brew | |
formula_folder: Formula | |
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
commit_owner: motdotenv | |
commit_email: [email protected] | |
install: 'bin.install "git-dotenv"' | |
test: 'system bin/"git-dotenv", "--version"' | |
target_darwin_amd64: true | |
target_darwin_arm64: true | |
target_linux_amd64: true | |
target_linux_arm64: true | |
update_readme_table: true | |
npm: | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Setup .npmrc file to publish to npm | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |