name: release on: push: branches: - dev - master jobs: tag_git: runs-on: ubuntu-latest permissions: contents: write outputs: tag_version: ${{ steps.set_tag_version.outputs.tag_version }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: check version run: cat VERSION - name: get version id: version run: | echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT" - name: Set tag version id: set_tag_version run: | if [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then echo "tag_version=${{ steps.version.outputs.version }}-pre" >> "$GITHUB_OUTPUT" else echo "tag_version=${{ steps.version.outputs.version }}" >> "$GITHUB_OUTPUT" fi - uses: actions/setup-go@v5 with: go-version: '>=1.17.0' check-latest: true # Install dependencies - name: Run tests run: | cd ./mkdotenv &&\ rm -rf ./tools &&\ go mod tidy &&\ go test ./... - name: Tag version id: tag_version uses: mathieudutour/github-tag-action@v6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} custom_tag: ${{ steps.set_tag_version.outputs.tag_version }} - name: Push tags run: git push --tags build_docker: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 - name: Login to Docker Hub if: github.ref == 'refs/heads/master' uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: release_image run: bash ./docker/build_docker.sh alpine_source: runs-on: ubuntu-latest needs: tag_git permissions: contents: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: make tar id: make_tar run: echo "tar_file=$(bash ./alpinebuild/make_tar.sh)" >> "$GITHUB_OUTPUT" - name: make apkfile run: bash ./alpinebuild/release_apkfile.sh - name: list file run: ls -l ./alpinebuild/${{ env.make_tar.tar_file }} - name: Upload Source Tarball uses: actions/upload-artifact@v4 with: name: mkdotenv-source-tar path: | ./alpinebuild/${{ env.make_tar.tar_file }} ./alpinebuild/APKFILE if-no-files-found: error alpine_apk: runs-on: ubuntu-latest needs: tag_git permissions: contents: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: make_apk run: | cd ./alpinebuild &&\ bash make_apk.sh &&\ ls -l ./release/home/x86_64 - name: Upload apk uses: actions/upload-artifact@v4 with: name: mkdotenv-apk path: | ./alpinebuild/release/home/x86_64/mkdotenv*-r0.apk if-no-files-found: error build_bin: runs-on: ubuntu-latest needs: tag_git permissions: contents: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-go@v5 with: go-version: '>=1.17.0' check-latest: true - name: build run: make bin COMPILED_BIN_PATH="/tmp/mkdotenv" - name: build_windows run: make bin OS=windows COMPILED_BIN_PATH="/tmp/mkdotenv.exe" - name: Upload Binary artifact uses: actions/upload-artifact@v4 with: name: mkdotenv-bin path: | ./bin/mkdotenv-linux-amd64 ./bin/mkdotenv-windows-amd64.exe if-no-files-found: error build_mac: runs-on: macos-latest needs: tag_git permissions: contents: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-go@v5 with: go-version: '>=1.17.0' check-latest: true - name: build_mac run: bash ./macos/build.sh - name: list_macos_bin run: ls -l ./bin - name: test execute run: ./bin/mkdotenv-darwin-arm64 --help - name: Upload Binary artifact uses: actions/upload-artifact@v4 with: name: mkdotenv-macos path: | ./bin/mkdotenv-darwin-arm64 ./macos/mkdotenv-macos.zip if-no-files-found: error - name: Upload Formula Atifact uses: actions/upload-artifact@v4 with: name: mkdotenv-macos-homebrew-formula path: | ./macos/bin/mkdotenv.rb if-no-files-found: error build_deb: runs-on: ubuntu-latest permissions: contents: write needs: tag_git steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Import GPG Key env: GPG_PRIVATE_KEY: ${{ secrets.GPG_SECRET }} run: | echo "$GPG_PRIVATE_KEY" | gpg --batch --import KEY_ID=$(gpg --list-secret-keys --keyid-format=long | awk '/sec/{print $2}' | cut -d'/' -f2) echo "DEB_SIGN_KEYID=$KEY_ID" >> $GITHUB_ENV - name: Cache APT packages uses: actions/cache@v4 with: path: | /var/cache/apt/archives key: apt-cache-${{ runner.os }}-${{ hashFiles('.github/workflows/build.yml') }} restore-keys: | apt-cache-${{ runner.os }}- - name: Install dependencies env: DEBIAN_FRONTEND: noninteractive run: | sudo apt-get update sudo apt-get install golang-1.23-go debhelper make build-essential debhelper equivs - name: Show Key ID run: echo "Using DEB_SIGN_KEYID=$DEB_SIGN_KEYID" - name: build run: bash ./deb/build_debian.sh - name: Upload DEB artifact uses: actions/upload-artifact@v4 with: if-no-files-found: error name: mkdotenv-deb path: ./deb/pkg/mkdotenv.deb build_rpm: runs-on: ubuntu-latest permissions: contents: write needs: tag_git steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - id: build_docker run: bash ./fedora/build_fedora_docker.sh - name: list rpms run: ls -l ./fedora/rpmbuild/RPMS/x86_64/ - name: rename rpm file run: cp "$(find ./fedora/rpmbuild/RPMS/x86_64/ -maxdepth 1 -type f | head -n 1)" ./fedora/rpmbuild/RPMS/x86_64/mkdotenv.rpm - name: Upload RPM artifact uses: actions/upload-artifact@v4 with: if-no-files-found: error name: mkdotenv-rpm path: ./fedora/rpmbuild/RPMS/x86_64/mkdotenv.rpm - name: rename srpm file run: cp "$(find ./fedora/rpmbuild/SRPMS -maxdepth 1 -type f | head -n 1)" ./fedora/rpmbuild/SRPMS/mkdotenv.src.rpm - name: Upload SRPM artifact uses: actions/upload-artifact@v4 with: if-no-files-found: error name: mkdotenv-srpm path: ./fedora/rpmbuild/SRPMS/mkdotenv.src.rpm release: runs-on: ubuntu-latest permissions: contents: write needs: - tag_git - build_bin - build_mac - build_deb - build_rpm - alpine_source - alpine_apk steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download Alpine Source code artifact uses: actions/download-artifact@v4 with: name: mkdotenv-source-tar - name: Download Alpine apk artifact uses: actions/download-artifact@v4 with: name: mkdotenv-apk - name: Download binary artifact uses: actions/download-artifact@v4 with: name: mkdotenv-bin path: ./bin - name: Download macos artifact uses: actions/download-artifact@v4 with: name: mkdotenv-macos path: . - name: "List Bin" run: ls -l ./bin - name: "List files" run: ls -l . - name: Download DEB artifact uses: actions/download-artifact@v4 with: name: mkdotenv-deb - name: Download RPM artifact uses: actions/download-artifact@v4 with: name: mkdotenv-rpm - name: Create a GitHub pre release uses: ncipollo/release-action@v1 if: github.ref == 'refs/heads/dev' with: tag: "v${{needs.tag_git.outputs.tag_version}}" allowUpdates: true prerelease: true artifacts: | ./bin/mkdotenv-linux-amd64, ./bin/mkdotenv-windows-amd64.exe, ./bin/mkdotenv-darwin-arm64, ./macos/mkdotenv-macos.zip, mkdotenv.deb, mkdotenv.rpm, mkdotenv*.tar.gz, APKFILE, mkdotenv*-r0.apk, ./aur/PKGBUILD bodyFile: RELEASE_NOTES - name: Create a GitHub release if: github.ref == 'refs/heads/master' uses: ncipollo/release-action@v1 with: tag: "v${{needs.tag_git.outputs.tag_version}}" allowUpdates: true prerelease: false artifacts: | ./bin/mkdotenv-linux-amd64, ./bin/mkdotenv-windows-amd64.exe, ./bin/mkdotenv-darwin-arm64, ./macos/mkdotenv-macos.zip, mkdotenv.rpm, mkdotenv.deb, mkdotenv*.tar.gz, APKFILE, mkdotenv*-r0.apk, ./aur/PKGBUILD bodyFile: RELEASE_NOTES test_homebrew: runs-on: macos-latest permissions: contents: write id-token: write needs: - release - build_mac steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download homebrew formula for macos uses: actions/download-artifact@v4 with: name: mkdotenv-macos-homebrew-formula path: ./macos/bin - name: Append -pre to release if: github.ref == 'refs/heads/dev' run: | sed 's|version "\(.*\)"|version "\1-pre"|' ./macos/bin/mkdotenv.rb > ./macos/bin/mkdotenv.mod.rb cp ./macos/bin/mkdotenv.mod.rb ./macos/bin/mkdotenv.rb - name: fix remote upon ./macos/bin/mkdotenv.rb run: sed -i -E "s|url.*|url \"https://github.com/pc-magas/mkdotenv/releases/download/v#{version}/mkdotenv-macos.zip\"|" ./macos/bin/mkdotenv.rb - name: Generate GitHub App token id: token uses: qoomon/actions--access-token@v3 with: repository: pc-magas/homebrew-mkdotenv permissions: | contents: write pull_requests: write - name: setup git and clone brew formula env: GH_PAT: ${{ steps.token.outputs.token }} run: | git config --global user.name "github-actions" git config --global user.email "actions@github.com" git clone https://x-access-token:${GH_PAT}@github.com/pc-magas/homebrew-mkdotenv.git cd homebrew-mkdotenv # Create new branch for PR git checkout -b test-update-formula-${{ github.run_number }} - name: setup formula run: | cd homebrew-mkdotenv mkdir -p ./Formula cp ../macos/bin/mkdotenv.rb ./Formula/mkdotenv.rb - name: test formula installation run: | cd homebrew-mkdotenv brew install nikitabobko/tap/brew-install-path brew install-path ./Formula/mkdotenv.rb # Verify it works by running the installed binary mkdotenv --version - name: Create Pull Request to homebrew repo env: GH_PAT: ${{ steps.token.outputs.token }} run: | cd homebrew-mkdotenv BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) # Create new branch for PR git add ./Formula/mkdotenv.rb git commit -m "Update formula via GitHub Actions" git push origin ${BRANCH_NAME} # Create a PR using GitHub CLI VERSION=$(grep -E '^ version ' ./Formula/mkdotenv.rb | sed 's/.*"\(.*\)".*/\1/') curl --fail-with-body -vvv -X POST https://api.github.com/repos/pc-magas/homebrew-mkdotenv/pulls \ -H "Authorization: Bearer $GH_PAT" \ -H "Accept: application/vnd.github+json" \ -H "Content-Type: application/json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ -d "{\"title\": \"Update formula [VERSION $VERSION]\",\"head\": \"$BRANCH_NAME\",\"base\": \"master\",\"body\": \"Automated update\"}" release_corpr: runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' permissions: contents: write needs: - release - build_rpm steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-python@v1 - name: install copr cli run: pip3 install copr-cli - name: create download dir run: mkdir -p ./fedora/rpmbuild/SRPMS - name: Download SRPM uses: actions/download-artifact@v4 with: name: mkdotenv-srpm path: ./fedora/rpmbuild/SRPMS - name: list downloaded srpm run: ls ./fedora/rpmbuild/SRPMS/mkdotenv*.src.rpm - name: Set up Copr config run: | mkdir -p ~/.config echo "${{secrets.CORPR_SETTINGS}}" > ~/.config/copr chmod 600 ~/.config/copr - name: upload to corpr run: | copr-cli build mkdotenv ./fedora/rpmbuild/SRPMS/mkdotenv.src.rpm