Repository navigation
Release Assets (1.0.0) #1
This file contains hidden or 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: Release Assets | |
| run-name: Release Assets (${{ inputs.tag }}) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Existing release tag to build and upload assets for" | |
| required: true | |
| type: string | |
| source_run_id: | |
| description: "Optional parent release workflow run id" | |
| required: false | |
| type: string | |
| source_run_url: | |
| description: "Optional parent release workflow run URL" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| packages: write | |
| concurrency: | |
| group: release-assets-${{ inputs.tag }} | |
| cancel-in-progress: false | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build-release-assets: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Linux arm64 | |
| runner: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| asset_target: unknown-linux-gnu-aarch64 | |
| binary_name: dotenv | |
| install_cmd: "" | |
| linker: "" | |
| - name: Linux x86_64 | |
| runner: ubuntu-24.04 | |
| target: x86_64-unknown-linux-gnu | |
| asset_target: unknown-linux-gnu-x86_64 | |
| binary_name: dotenv | |
| install_cmd: "" | |
| linker: "" | |
| - name: Linux static (musl) arm64 | |
| runner: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-musl | |
| asset_target: unknown-linux-musl-aarch64 | |
| binary_name: dotenv | |
| install_cmd: sudo apt-get update && sudo apt-get install -y musl-tools | |
| linker: musl-gcc | |
| - name: Linux static (musl) x86_64 | |
| runner: ubuntu-24.04 | |
| target: x86_64-unknown-linux-musl | |
| asset_target: unknown-linux-musl-x86_64 | |
| binary_name: dotenv | |
| install_cmd: sudo apt-get update && sudo apt-get install -y musl-tools | |
| linker: musl-gcc | |
| - name: Windows x86_64 | |
| runner: ubuntu-24.04 | |
| target: x86_64-pc-windows-gnu | |
| asset_target: pc-windows-gnu-x86_64 | |
| binary_name: dotenv.exe | |
| install_cmd: sudo apt-get update && sudo apt-get install -y mingw-w64 | |
| linker: "" | |
| steps: | |
| - name: Resolve release tag | |
| id: meta | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [ -n "${{ inputs.tag || '' }}" ]; then | |
| echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "No release tag was provided." >&2 | |
| exit 1 | |
| fi | |
| - name: Check out tagged source | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ steps.meta.outputs.tag }} | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install target-specific build tooling | |
| if: matrix.install_cmd != '' | |
| shell: bash | |
| run: ${{ matrix.install_cmd }} | |
| - name: Run tests | |
| if: matrix.target == 'x86_64-unknown-linux-gnu' | |
| run: cargo test --locked --all-features | |
| - name: Build release binary | |
| shell: bash | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.target == 'aarch64-unknown-linux-musl' && matrix.linker || '' }} | |
| CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.target == 'x86_64-unknown-linux-musl' && matrix.linker || '' }} | |
| run: cargo build --locked --release --target ${{ matrix.target }} | |
| - name: Package tar.gz archive | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| asset="dotenv-cli-${{ steps.meta.outputs.tag }}-${{ matrix.asset_target }}.tar.gz" | |
| tar -C "target/${{ matrix.target }}/release" -czf "$asset" "${{ matrix.binary_name }}" | |
| echo "ASSET_PATH=$asset" >> "$GITHUB_ENV" | |
| - name: Upload asset to GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release upload "${{ steps.meta.outputs.tag }}" "$ASSET_PATH" --clobber | |
| - name: Add run summary | |
| shell: bash | |
| run: | | |
| { | |
| echo "## Release Assets" | |
| echo | |
| echo "- Tag: \`${{ steps.meta.outputs.tag }}\`" | |
| echo "- Target: \`${{ matrix.target }}\`" | |
| if [[ -n "${{ inputs.source_run_url }}" ]]; then | |
| echo "- Triggered by: ${{ inputs.source_run_url }}" | |
| fi | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| publish-release: | |
| name: Publish release | |
| needs: build-release-assets | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Check out release tag | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ inputs.tag }} | |
| - name: Publish release and trigger Homebrew tap update | |
| id: finalize | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| RELEASE_VERSION: ${{ inputs.tag }} | |
| run: devops/release/finalize-release.sh | |
| - name: Set up Node for npm | |
| if: steps.finalize.outputs.published == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install package dependencies | |
| if: steps.finalize.outputs.published == 'true' | |
| run: npm ci --ignore-scripts | |
| - name: Publish to npm | |
| if: steps.finalize.outputs.published == 'true' | |
| run: npm run publish:npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Set up Node for GitHub Packages | |
| if: steps.finalize.outputs.published == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://npm.pkg.github.com | |
| - name: Publish to GitHub Packages | |
| if: steps.finalize.outputs.published == 'true' | |
| run: npm run publish:github | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |